How do I move a sub string of JSON into a new dictionary

Get help using Construct 2

Post » Fri Jun 12, 2015 3:16 am

I have an api built that contacts the server and gets a billboard message and tasks.

billboard
Code: Select all
{"result":"success","returned":"billboard message"}


task
Code: Select all
{"result":"success","returned":[{"id":"1","task":"blah", "description":"blah"},{"id":"2","task":"blah", "description":"blah"}]}


I make an AJAX call, and load it into a dictionary like so:

Image

When I set text to AJAX_RESULTS.Get("returned") for the billboard it will display the string, but when I set the text after calling tasks it displays "0".

I tried Load from JSON string "{""c2dictionary"":true,""data"":" & AJAX_RESULTS.Get("returned") a & "}" into a different dictionary and tried to set the text to AJAX_RESULTS.Get("id") but that also returned 0.
B
12
S
2
Posts: 6
Reputation: 610

Post » Fri Jun 12, 2015 6:16 am

Yes, billboard->returned is a string and task->returned is an array. (look at details, there are no quotes)
Construct cant handle Arrays/Objects like this, so it shows 0. (null)

AJAX_RESULTS.Get("id") dont exist. There is only index 0 and 1 in this array. (not a dictionary!)

I dont know the default way to get for example the id value of for example index 0 from returned of AJAX.LastData, in this I cant help you.

I personally would make it like this, with my plugin:
Image
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303


Return to How do I....?

Who is online

Users browsing this forum: bluesun66, jasontoups and 1 guest