How do I Load a dictionary from a file

Get help using Construct 2

Post » Sun Jan 25, 2015 5:34 am

I am trying to load a dictionary from a project file. I see how to read it using an ajax object, but I am not sure how to take that data and load it into the dictionary.

I setup a trigger for when Ajax is completed. I then add a dictionary load action and load from Ajax.LastData, but it isn't loading into the dictionary. I can send it to a text box and I see the data from the file, but the dictionary data doesn't change/load.

Here is the string that is in the file (exact):
{"c2dictionary":true,"data":{"ColorTV":0,"Freezer":1,"Suit":2"Refrigerator":3,"Stove":4}}

Any suggestions?
B
7
S
2
Posts: 10
Reputation: 495

Post » Sun Jan 25, 2015 8:37 am

Image
B
16
S
7
Posts: 126
Reputation: 1,910

Post » Sun Jan 25, 2015 9:16 am

EstudioCelula3 wrote:https://www.scirra.com/forum/load-json-string-into-dictionary_t72836


Thank you for the reply, but that forum post doesn't help me as that is working with a static string directly in the action, not reading from a file.
B
7
S
2
Posts: 10
Reputation: 495

Post » Sun Jan 25, 2015 9:35 am

Is your project file in JSON format?

You can to check this too: https://www.scirra.com/store/game-makin ... editor-124
Image
B
16
S
7
Posts: 126
Reputation: 1,910

Post » Sun Jan 25, 2015 9:52 am

EstudioCelula3 wrote:Is your project file in JSON format?


The json example I provided is exactly what is in my file. I have also exported a dictionary, disabled the actions to add data to the dictionary so it is empty and tried to load that same file back into the dictionary and it didn't work. I know the file is being read as it successfully writes to a text box.
B
7
S
2
Posts: 10
Reputation: 495

Post » Sun Jan 25, 2015 11:10 am

It's strange, because the process is correct:
- Download Dictionary data in JSON format
- Import the file in the project
- Call the file in project via Ajax
- Load the file via Dictionary using Ajax expression

If you did these steps, then it's not to have errors.
Image
B
16
S
7
Posts: 126
Reputation: 1,910

Post » Sun Jan 25, 2015 3:22 pm

EstudioCelula3 wrote:If you did these steps, then it's not to have errors.


I agree with you and I will chalk this one up to doing this stuff at 3AM. I recreated this morning and all is good. Thank you for your time.
B
7
S
2
Posts: 10
Reputation: 495


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Buddhika, R0J0hound, Unconnected and 16 guests