How do I load data from Json string

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

    Eg.

    {"c2array":true,"size":[30,8,4],"data":[]}

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

    "{""c2array"":true,""size"":[30,8,4],""data"":[]}"

    Thanks again, at least I know now how it all works and hope that it can and going to be changed in a future release.

  • You can have your level editor export the data in the correct format like this:

    [attachment=0:3nbexz0a][/attachment:3nbexz0a]

    Still I'd just use project files unless you've tested it and it's noticeably slower.

  • You can have your level editor export the data in the correct format like this:

    [attachment=0:ih73yfp5][/attachment:ih73yfp5]

    Still I'd just use project files unless you've tested it and it's noticeably slower.

    Thanks I'm going to test it right away

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why don't you program the level editor to save as an array and when saving just save that array as JSON? Set key to arrayName.AsJSON would do that and guarantee everything is right...

  • Thanks ramones it works like a charm, you made my day

    Why don't you program the level editor to save as an array and when saving just save that array as JSON? Set key to arrayName.AsJSON would do that and guarantee everything is right...

    that's what I did but won't work like that.

  • Weird

  • This is the way that I use it (I load my levels on game start in array from AJAX file)

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