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

0 favourites
  • 2 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • I have an api built that contacts the server and gets a billboard message and tasks.

    billboard

    {"result":"success","returned":"billboard message"}[/code:2xwjghkx]
    
    [b]task[/b]
    [code:2xwjghkx]{"result":"success","returned":[{"id":"1","task":"blah", "description":"blah"},{"id":"2","task":"blah", "description":"blah"}]}[/code:2xwjghkx]
    
    I make an AJAX call,  and load it into a dictionary like so:
    
    [img="http://i.imgur.com/8T3al60.png"]
    
    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.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)