How do I put a Json into array ?

Get help using Construct 2

Post » Tue May 27, 2014 11:21 pm

My teste like the image in attach load the json file below:

[{"nr":1,"txt":"Curitiba","eCorreta":false,"img":"imagem01.png","x":600,"y":100},{"nr":2,"txt":"Santos","eCorreta":true,"img":"imagem02.png","x":800,"y":200}]

When I click on the button, I got the content below e not the json content above. What is the problem ?

{"c2array":true,"size":[10,1,1],"data":[[[0]],[[0]],[[0]],[[0]],[[0]],[[0]],[[0]],[[0]],[[0]],[[0]]]}


thanks,

José Roberto.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 26
Reputation: 277

Post » Tue May 27, 2014 11:22 pm

Use ajax. Load as project file.
Image ImageImage
B
169
S
50
G
173
Posts: 8,317
Reputation: 110,278

Post » Tue May 27, 2014 11:34 pm

Hello Newt.
Are you talking about Ajax (request project file) like the attach ? I got the same problem.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 26
Reputation: 277

Post » Tue May 27, 2014 11:48 pm

Make sure the file is an actual project file by adding it under files, then use the on finished loading ajax using the tag you give it.
Don't use the button, unless you are for sure the file is loaded
Then set the text to the return value ajax gives.
ajax.lastdata
Image ImageImage
B
169
S
50
G
173
Posts: 8,317
Reputation: 110,278

Post » Wed May 28, 2014 12:08 am

I did like the attach. I goth the same error. I'm sure the json file is in the project.
Is my json file in a format the C2 unsderstand?

[{"nr":1,"txt":"Curitiba","eCorreta":false,"img":"imagem01.png","x":600,"y":100},{"nr":2,"txt":"Santos","eCorreta":true,"img":"imagem02.png","x":800,"y":200}]
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 26
Reputation: 277

Post » Wed May 28, 2014 12:25 am

No, it's not. The easiest thing to do is to build a small sample array in C2 with a few elements, then dump out the JSON to see the format. Then just follow the same format for your real data. It should then work.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994


Return to How do I....?

Who is online

Users browsing this forum: TRMG and 29 guests