Can somebody PLEASE help me with this JSON question ?

Discussion and feedback on Construct 2

Post » Mon Sep 28, 2015 12:14 pm

{"Row":{"id":"1","Item_Name":"Bushfly","Image_Path":"Monsters/Bushfly.png","Quantity":"1", "Description":"It's a Monster.","Seller":"Mr. Garrison","Star_Cost":"1","Category":"Monster"},"Row":{"id":"2","Item_Name":"Jebbie","Image_Path":"Monsters/Jebbie.png","Quantity":"1", "Description":"","Seller":"","Star_Cost":"1","Category":"Monster"}}

I am so stuck I can't even see tomorrow, so I loaded this data into a String variable.

Construct 2 doesn't have a JSON object so I was hoping is there a way I could retrieve Row[1].Item_Name ? Result will be Jebbie since start from Zero.

I really need help please someone help me.
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Mon Sep 28, 2015 1:44 pm

There is a third party json plugin by yann. That said that doesn't look like a valid json string. You can't define row twice like that I don't think.

You could use the browser object to try to parse it.
Browser.evaljs("var a="&variable&"; a.row.item_name")
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Mon Sep 28, 2015 3:20 pm

Oh....what would be the proper format ? Can you format it for me as an example so that I can fix the output ?
I use php to manually string up this JSON so with your guided example, I will be able to correct it :)
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Mon Sep 28, 2015 3:43 pm

This should help:
http://www.w3schools.com/json/json_syntax.asp

For a list you'd put it inside []
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455


Return to Construct 2 General

Who is online

Users browsing this forum: mhls and 1 guest