Data import: csv or json?

afasol

Member
Hi all,

for the purpose of importing data into gml, is there any specific reason to prefer csv over json format? I do not have an actual case or application at hand, it's more of a general question. But as a vanilla example, let's say something like data describing a number of monsters or NPCs, with the data being monster name, HPs, damage, for N monsters.

Did a little research on the forums on my own, but found nothing, so my apologies in advance if the answer was right in front of my eyes all along but I still did not spot it.

Cheers
 

obscene

Member
Personally I recommend CSV....

1) You can view it as a spreadsheet which makes it easy to understand and manage.
2) You can convert it to a grid with a single line of code.

Whatever it is about JSON that everyone seems to like, I don't get it, but maybe I'm oldschool.
 

Appsurd

Member
If your file is large, then json is preferable, because GMS takes less time to convert json to ds_map than CSV (at least from my experience from about 3 years ago)

With large, I mean at least thousands of key,value pairs
 
Personally, JSON often comes as a first choice. I really dislike CSV, and go with TSV if I have absolutely no other choice and can't use JSON for whatever reason.
CSV can possibly **** you up if you try to store, for example,[1,6] as a value. At least a TSV will use Tabs, and not commas.
JSON is fun because it's a literal syntax, easy to write and easy to read, and you can nest infinitely.
 

4i4in

Member
like data describing a number of monsters or NPCs, with the data being monster name, HPs, damage, for N monsters.
If You run Your game on array, ds or another easy to storage "big number" json is easy to use as in manual.
 

afasol

Member
Thanks everyone for chipping in!

Still (as obscene pointed out) viewing/editing json files doesn't look to me as immediate as with csv. So with jsons, would the workflow look something like the following?

prepare your data on spreadsheet --> convert to json with some script (python, vba, web) --> read in gml with json_decode or json_parse

Cheers
 

Appsurd

Member
As Slow fingers said. But I wanted to add that if you know a little Python, you can easily make something like that yourself.
 
Top