C3 JSON Syntax

0 favourites
  • 9 posts
From the Asset Store
Jump on the mole rats and see how far you can go!
  • Sorry, dumb question, but i need the syntax for the JSON file that will load from the URL, all i have to go off of is:

    {"c2array":true,"size":[5,1,1],"data":[[["tiger"]],[["rabbit"]],[["mouse"]],[["lion"]],[["cow"]]]}

    but this doesn't load, obviously made for C2, so what is c3 Syntax?

    I've tried to use "Load from JSON String" into my array, nothing loads, and i point at that information which is in a json file on my web server.

    Thanks

    (again, sorry for stupid question here, but can't find any tutorials that contain this info and the manual doesn't contain the layout either)

  • The general format is correct for C3. Everything is specified as 3d array basically. Here are examples

    3d

    {

    "c2array": true,

    "size": [ 2, 3, 4 ],

    "data": [ [ [ 100, 200, 300, 400 ],

    [ 101, 201, 301, 401 ],

    [ 102, 202, 302, 402 ]

    ],

    [

    [ 110, 210, 310, 410 ],

    [ 111, 211, 311, 411 ],

    [ 112, 212, 312, 412 ]

    ]

    ]

    }

    2d & 1d, depending how you look at it

    {

    "c2array": true,

    "size": [ 1, 4, 1 ],

    "data": [ [ [ 1 ],

    [ 2 ],

    [ 3 ],

    [ 4 ]

    ]

    ]

    }

    {

    "c2array": true,

    "size": [ 4, 1, 1 ],

    "data": [ [ [ 1 ]

    ],

    [

    [ 2 ]

    ],

    [

    [ 3 ]

    ],

    [

    [ 4 ]

    ]

    ]

    }

  • I also created a json manager plugin that is on the add on page that can load a standard json file and then output a portion of it to a c3 array and c3 dictionary.

  • Thanks, then i must be doing something really wrong, i have my array, i have it set to load from json, giving it a url of "https://www.cyborgsattack.com/files/ScriptedConversation.json" but this doesn't load anything into my array.

    i would have expected that my array.at(0) would have a number 1 in it, but it has 0 in all array elements

  • Do you see any error messages in the console ?

  • No, i have switched on the developer console in chrome but nothing stands out, my logic is simple, on layout load, load from Json into array

  • Are you using the ajax control to get the data string first ?

    Once you get the data/string from the ajax call, you load the array with the string you just got.

  • I just created a dummy project and read that url in using ajax and then populated the array.

    I then used the browser control to disply Array.At(0) and I get 1. So it appears to be working

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks, that was the steps i was needing and missed, i presumed that the array load would allow me to load from source being a URL to the json, i looked everywhere for this information that you graciously provided to me, sample projects like this short and sweet example really need in the docs, thanks again rhg1968

    3 very important things here that need addressed in the documentation

    1) how to structure your json data for Construct 3

    2) using ajax to capture the data in a download from a url

    3) using the array load to then move that data into the array

    and a very important 3a, when you load it in, the array is essentially overwritten, not appended to, so a LoadAppend would be nice, although impractical right now based on how it is coded

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