How do I Load a json file to a dictionary

Get help using Construct 2

Post » Sun Jan 10, 2016 12:02 am

Message: franmcod can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
hey i'm have read some post about this, and i'm not sure where is my mistake...
https://gyazo.com/47b6a5238c5f82cf4c9ed9f6e98c8011

The Ajax.LastData returns { "0":null,
"1":"bronze sword",
"2":"bronze pickaxe",
"3":"bronze axe"

but the dictionary it self is still empty :(
B
9
S
3
Posts: 32
Reputation: 708

Post » Sun Jan 10, 2016 1:12 am

You have to use the right format for C2. Use the dictionary's download as JSON action to see what it should look like.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Sun Jan 10, 2016 1:23 am

@franmcod

Try this plugin.
B
107
S
25
G
231
Posts: 4,361
Reputation: 131,412

Post » Sun Jan 10, 2016 1:26 am

it gave an .json with this {"c2dictionary":true,"data":{}}, i've read something about double quotes, is it that? so something like { ""0"":null,
""1"":""bronze sword"",
} ?
B
9
S
3
Posts: 32
Reputation: 708

Post » Sun Jan 10, 2016 1:33 am

@rexraibow that is cool but i would like to avoid plugins for something so simple, i'll try to parse it manually and add to the dictionary...
B
9
S
3
Posts: 32
Reputation: 708

Post » Sun Jan 10, 2016 1:38 am

You don't need the extra quotes if you're loading from a file. You just need it like this:
Code: Select all
{"c2dictionary":true,"data": {"1":"bronze sword", "2":"bronze pickaxe","3":"bronze axe"}}


There's no null. The C2 dictionary only holds numbers and strings. Also if your keys are just numbers you might use an array.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Sun Jan 10, 2016 1:47 am

@ramones solved it, thx alot!!!
B
9
S
3
Posts: 32
Reputation: 708


Return to How do I....?

Who is online

Users browsing this forum: alajajm, imhotep22, jance0405, Solomon and 12 guests