How do I save an Array in an Array?

0 favourites
  • 5 posts
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • Hello,

    I have a question to Arrays in C3:

    I made a function to save some Userstats in a mysql database.

    To load these data, I just make an AJAX request and the answer will be a C3-Array like this:


    So I do something like this:

    "myLoadArray = load from JSON string AJAX.lastdata"

    Then I can access all the data from the "myLoadArray".

    This works fine.

    But now my problem:

    I also save complete arrays...

    For example in I stored a full array, then it would look like this:


    And this doesn't work. I pretty sure the problem are the quotation marks.

    But how can I fix that? Working with "'" + """ like this:


    also doesn't work...

    Thanks for your help!

  • Maybe it would be easier to store the arrays in a Dictionary as strings, or you can store array data as strings, in the array and get the data with tokenat expression?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Embedding a JSON string inside another string requires the correct escaping of quotes. JSON must use double quotes ("), single quotes are not allowed. If you're pasting it in a Construct expression then double quotes must be doubled to "" to count as a single character, and not the character that ends the string expression. If you're using it as JSON then " must be escaped as \" inside another string.

  • Hey,

    thank you for the help!

    So the response from the AJAX-Call should look like this?


    And then I can do this:

    myArray = load from JSON string AJAX.lastdata

    myArrayInArray = load from JSON string myArray.At(9)

    Should this work?

    Best regards and thank you!


    Tested it like described above and it worked :)

    Thank you for the help!

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