How do I put a Json into array ?

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use ajax. Load as project file.

  • Hello Newt.

    Are you talking about Ajax (request project file) like the attach ? I got the same problem.

  • 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

  • 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}]

  • 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.

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