Load JSON String Into Dictionary

0 favourites
  • 8 posts
  • Hello, does anyone know of a way to get this JSON string:

    {"0":"20","1":"2","2":"6","7":"29"}

    Into a Dictionary Object? I thought it might of been the Load Action but I may have been incorrect.

    Any tips on getting the string above into a dictionary?

    Thanks!

    -T

  • Try saving JSON out the Dictionary object and inspecting the result. It uses its own slightly different format. Make your JSON in the same format and it should load just fine.

  • Try saving JSON out the Dictionary object and inspecting the result. It uses its own slightly different format. Make your JSON in the same format and it should load just fine.

    I did think of that. I get the below "Syntax Error."

    Let me know if i'm missing something.

    I used:

    {"c2dictionary":true,"data":{"5":1}}

    And:

    "{"c2dictionary":true,"data":{"5":1}}"

    <img src="http://i.imgur.com/7uewS.png" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Double-quotes start and end strings in Construct 2 expressions, so you can't paste it in like that. You need to use this:

    "{""c2dictionary"":true,""data"":{""5"":1}}"

    because "" turns in to a single " inside a string. It might be easier to save it to a text file, import the text file to the project, and AJAX request it. See using project files.

  • Double-quotes start and end strings in Construct 2 expressions, so you can't paste it in like that. You need to use this:

    "{""c2dictionary"":true,""data"":{""5"":1}}"

    because "" turns in to a single " inside a string. It might be easier to save it to a text file, import the text file to the project, and AJAX request it. See using project files.

    That did it. Thanks again.

  • Hello,

    How would the json dictionary string be if i want to insert a json array ?

    Thanks

  • Hello,

    How would the json dictionary string be if i want to insert a json array ?

    Thanks

    It would be:

    array.asjson[/code:1bb6e2y8]
  • DuckfaceNinja

    Thank you very much

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