Loading JSON into array

0 favourites
  • 8 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • Apologies if this is user error but have tried this with a variety of JSON files and nothing is loading into the array properly. Clearly the AJAX request is fine but then the "Load from JSON string AJAX.LastData" doesn't properly convert the JSON to array...


    Thanks for any help!


  • Firstly, the JSON snippet you have used is more like a dictionary map than an array. It's not a sequence of elements, it's associating "success" with "true", and so on. This is a better fit for the Dictionary plugin which is coming in the next beta.

    Secondly your JSON must be in a special format for Construct 2 - look at the value returned from Array's AsJSON expression for a 1 x 1 x 1 array:

        "c2array": true,
        "size": [1,1,1],

    Your JSON must also match this format for Array. It's designed to only be used with JSON returned from other Array objects.

  • Thanks Ashley, hugely useful!

  • I want to add a note here (and I have to thank Ashley's above clarification for the hour or so I spent deriving this solution), but if you're loading a JSON object from a server, you'll want to make sure it's a 3-dimensional array, and that, for example --and this was my issue-- if you have a 2-dimensional array, you'll have to set it up as a 3-dimensional array anyway with all entries set on 0z. (E.g [123][45][0] in php will serialize correctly with json_encode() as opposed to [123][45]. Similarly, for a 1d array, you'll have to place all entries on the 0y 0z plane.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Good point mucks! Cheers!

  • Hi,

    Facing same kind of problem, can you please put some example to to display data for particular position

    Below is my received json data




    "data":[ [[4837],["test2"],[2],["1"]],


    [700],["test6"],[6],["5"]], [

    [600],["test1"],[1],["4"]], [

    [30],["test1"],[1],["3"]], [

    [10],["test1"],[1],["1"]], [



  • dapankaj

    This is a 3 year old closed bug report you have pointlessly bumped with what is just a 'How Do I' type question.

    You should probably post such a question in the correct part of the forum, if you hope to get a good response.

  • zenox98,


    And thnx for your response, can you please suggest correct part of the forum,so that i can post.

    Because l am confused with this question thread is coming from ?

    Yesterday i had posted one question ( www . scirra .com / forum/ viewtopic.php?f=147&t=128374) Correct me if that one belongs to wrong part of forum

    Cannot insert link here

    Thank you

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