JSON AJAX to Array

0 favourites
  • 2 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Greetings, im trying to do some stuff with dynamic data from a AJAX php site this is my json result:

    [quote:stm96qa5]

    {

    "c2array": true,

    "size": "[1,2,10]",

    "data": [ { "nombre": "John Smith", "puntos": 100 }, { "nombre": "John Smith", "puntos": 200 }, { "nombre": "John Smith", "puntos": 300 }, { "nombre": "John Smith", "puntos": 400 }, { "nombre": "John Smith", "puntos": 500 }, { "nombre": "John Smith", "puntos": 600 }, { "nombre": "John Smith", "puntos": 700 }, { "nombre": "John Smith", "puntos": 800 }, { "nombre": "John Smith", "puntos": 900 }, { "nombre": "John Smith", "puntos": 1000 } ]

    }

    Im trying to add this to an array using this:

    [quote:stm96qa5]On Ajax completed: Array - Load from JSON string AJAX.LastData

    On debug i can't see anything loaded to my array

    What im doing wrong ?

    If anyone can upload a .capx example with an ajax to array i appreciate it.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • System | On start of layout (or whenever you need it)- Request whatever.json (tag "whatever")

    AJAX On "whatever" completed - Array | Load from JSON string ajax.LastData

    Really all there is to it...

    Still having trouble, upload a .capx and someone'll help, i'm sure!

    EDIT: oh, one more thing, and I'm not positive it matters, but it might, aside from the very beginning and very end, my JSON files don't use any of these brackets: { }, only these: [ ]

    I think it might have to do with the setup of your JSON file...

    see if this makes sense, starting at the word "data"

    "data": [[["x0"], ["x1"], ["x2"]],[["y0"],["y1"]],[["z0"],["z1"]]]}

    at least, looking at some of mine, that's the format they're in.

    hope that helps!

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