Why use buffers and json ?


I've used ini files before for saving / loading but I was wondering why and when you'd use buffers/json.
Why would you use one over the others?



Your Creator!
The ini functionality has been there for a very, very long time. Ini files are actually only meant for configuration but many people have used them for saving data.
There isn't much to say for one over the other except that json is newer in gm. The JSON format is actually quite extensive and you aren't quite able to take full advantage off it in GM.
Still if you are using maps and lists anyways to store data, using JSON is a super easy plug n' play way of saving/loading. So that's when it comes down to preference.


With buffers, a nice way to think about them is as a tool used to temporarily store data before moving it somewhere else. You get this a lot in networking where for example, you have a buffer that stores information about player data before sending it across the network. Another use for a buffer could be to load map data before using the map information to render and do collision checking later (i.e generating produral terrain in chunks)


aka fel666
with INI your data has to be quite flat. You get sections, and keyvalue pairs in those sections but that is it.
With JSON you get to go as deep as you need. and not only do you get to represent key value pairs (using objects) but also lists of items.
Both INI and JSON are encoded as text. so reading and ssaving them is slower, and they also take up more space on disk.
Not only that but text is not always ideal when representing some data (ie numbers).
Buffers allow you to write your data in any format you like (text or binary) so you get the most flexibility out of it.
It should be noted that buffers are just a way to interface with the machines memory. As such its perfectly possible to store INI or JSON using buffers.

The JSON format is actually quite extensive and you aren't quite able to take full advantage off it in GM.
How so, JSON has lists and objects. those map exactly to GMs lists and maps. am I missing something?

Why would you use one over the others?
I would say:
Use INI when you have fairly flat data that needs to stay human readable and editable. IE configuration.
Use JSON when you have a deeper data structure that also needs to stay human readable. IE level data, asset manifest, save data...
Use Binary when the data does not need to be human readable and saving and loading quickly is important. IE level data, network packets, game assets....