How do I load data from Json string

0 favourites
  • the problem is that my old capx files with array loading from Json string suddenly stop working//// They were working before, but now i have a problem on all browsers Maybe i miss somsing i update construct for 188-189 and today for 190 versions.

    p.s sry for my Eng.

  • Hi Nagval333 did it stop working after upgrading to a beta version?

  • I was working always with a beta versions (maybe it's a mistake///iam pretty newbie in all this), but yes i regularly upload it, and last time i used it in 186 version and it work fine/// Now 188 and 190 make problem. The interesting thing that arrays uploading from AJAX ( json files ) still perfect working.

  • I'm pretty much a noob too and I read that the beta versions are really intended only for people with more experience who can cope with things going wrong (as they'll know that their own code is right) - as I understand it, you and I are better off sticking with the latest "stable" version (r184)

  • Hey - sorry, I've just checked and see that r190 was released yesterday as a stable version!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's the tabs in the string that are causing the problem.

  • "ramones" can you (or someone else) show me what i have to change for make it work? All caps that use this function stop working, its a bit of sad.

  • Your JSON string has

  • LOl

    characters in it:

    		[[0],[0],[0], [0],[0],[0],[0]],
    I guess you copy/pasted it from another editor. If you remove the tabs (replace them with spaces) it works.
    Maybe make a bug report if it worked before.
  • Thank you very much "ramon", now its work. Honesty i have no idea how to write this correct from start, i just copy/paste this example capx and fill with my data (i have even download "Sublime Text 2"). Anyway tnx again!

  • [quote:3egzw1zh]Your JSON string has

  • LOl
    characters in it:
  • Code: Select all




    ""data"":[ [[0],[0],[0], [0],[0],[0],[0]],


    [1],[-1],[-1],[-1],[-1],[14],[26]], [

    [2],[30],[10],[8],[-1],[-1],[-1]], [




    I guess you copy/pasted it from another editor. If you remove the tabs (replace them with spaces) it works.

    Thanks this work perfect,

    but why is c2 still saving it in wrong format (or I'm missing something)? I made a level editor in version 192 and it save still like this:


    and can't load it in a normal way in to a array or am I missing something?

    I like to put the level data in c2 project files (like music etc.) so it get compiled with the code.

    Struggling for days with this now and hope that some one can help me with this.

  • Steely What's wrong with it? It's not loading from a project file?

  • Hi ramones, thanks for your reply,

    I got it working if I load it direct in the array with ajax (finaly) but I wanted it to do different now, because I don't know if it all loads fast enough in a android app, so I wanted to copy my data (txt) files from the level editor direct in the c2 code as dictionary keys key 1 to 30 (or more) for example.

    The levels are created out of this 30 different level parts to generate random levels.

  • It should be possible to load from a dictionary key... Can't see why this is not working.

  • I want that the level editor save in the right format so I can copy and pasta the txt file direct in the dictionary key without to edit the file because when I get a typo in there its mesh up the whole system.

  • Right, the editor expects you to enter a string so you have to put it in quotation marks and you have to escape any quotation marks inside the json string with double quotation marks.



    will work when loaded from a file but if you want to paste into an event you have to change it to:


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