load an array with JSON

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • From various posts, I have guessed at the JSON format required to load an array.

    Its for looking up the "th" string, e.g.

    "1" & array.at(1)

    should result in "1st" etc.

    I tried loading it with this string:

    "{

        ""c2array"": true,

        ""size"": [75,0,0],

        ""data"":[1:""st"",2:""nd"",3:""rd"",4:""th""]

    }"

    I also tried this:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[1:""st"",2:""nd"",3:""rd"",4:""th""]]]

    }"

    and this:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[""na"",""st"",""nd"",""rd"",""th""]]]

    }"

    and a million other formats.

    The ones which dont throw a runtime error, all print "10", i.e. they get back zero from the array.

    Anyone know the required JSON format to load an array (or dictionary).

    Thanks!

  • OK, sussed it. The correct format is:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[""na""]],[[""st""]],[[""nd""]],[[""rd""]],[[""th""]]]

    }"

    Doesn't seem logical, but I guess thats JS for you!

  • why do u have double double quotes or quad single quotes?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to uses double double quotes quotes to put a single double quote in a string.

    It's the equivalent of using \" in other languages.

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