How do I take this CSV make it JSON & load into an Array

0 favourites
  • 5 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • Hey Everyone,

    I'm trying to import a large csv (deliminated by commas) into my game with the ability to change global variables to values located in the array.

    Some questions:

    What is the exact format of the JSON file does it need to be in? I've seen things about tweaking the format of standard JOSN

    Anyone have a good source to convert CSV to JSON?

    Thank you!

    Bryan

  • For a 3D array you want your JSON in this format:

    {

    "c2array":true,

    "size":[2,3,4],

    "data":[ [ [0,1,2,3], [4,5,6,7], [8,9,10,11] ],

    [

    [12,13,14,15], [16,17,18,19 ], [20,21,22,23] ]

    ]

    }

    For 2D like this:

    {

    "c2array":true,

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

    "data":[ [ [0], [1], [2] ],

    [

    [3], [4], [5] ]

    ]

    }

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much! This format works for what i want to do, i just don't know the easiest way to convert a standard csv to this format without manually editing it.

    For a 3D array you want your JSON in this format:

    {

    "c2array":true,

    "size":[2,3,4],

    "data":[ > > [ [0,1,2,3], [4,5,6,7], [8,9,10,11] ],

    [ [12,13,14,15], [16,17,18,19 ], [20,21,22,23] ]

    ]

    }

    For 2D like this:

    {

    "c2array":true,

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

    "data":[ > > [ [0], [1], [2] ],

    [ [3], [4], [5] ]

    ]

    }

  • This tool gets you close, if you choose CSV to JSON array in step 5:

    http://www.convertcsv.com/csv-to-json.htm

    Annoyingly it doesn't add sets of brackets around each y value, but on the plus side you can add double quotes in step 3, if you're using strings.

    You might be able to use the custom options in step 4 to get exactly what you need, haven't tried it out yet.

  • Rex's CSV2Array plugin may help you, but it is only available for C2, as far as I'm aware.

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