# Alternative to JSON and XML?

This topic is 1129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

But is richness a good thing in most use-cases? The main reason I advocate YAML over XML is it's simplicity - if you don't need schema validation, XPath, XSLT, or any of the other fancy addons to XML, it's just so much added cruft.

Exactly. Simplicity is key here. I'd use INI files if I didn't need to store other types of data than just simple values.

##### Share on other sites
I've never liked XML, and I have many of the same objections to JSON that you do. I'm not aware of any library that does exactly as you are asking for, though. Personally, I like to use Lua for my game files and data. It's quite handy for data description, even if I don't use it as an embedded script but just to load and move data.

Interesting. I've heard of Lua being used for data storage, and it certainly has a decent syntax for it. But how complex is it to read and write values? I always assumed you had to load up the file into a Lua VM, then perform stack calls into the VM to access your data. Which sounds overly complex when compared to other JSON/XML library APIs.

Pretty much this. Until recently I used Lua for this kind of thing extensively, but unless you like writing lots of tedious stack calling to get your data, you have to code an extra interface layer to allow Lua to build and populate your objects directly. Thanks to swiftcoder in this thread, I started using yaml-cpp and I have to say I'm a fan. Building a YAML node manually or reading data from a node are dead simple using the "new" interface, and structurally my data is very similar to a Lua table, as long as I only need data and not Lua functions-as-data.

Note that the yaml-cpp stable build is for the "old" interface which is apparently much clunkier; grab the latest build from the repository which supports syntax such as [code]node["x_resolution"]=1280[/code] and [code]bool fullscreen=node["fullscreen"].as<bool>();[/code] so streaming data in an out is a breeze.

##### Share on other sites

Pretty much this. Until recently I used Lua for this kind of thing extensively, but unless you like writing lots of tedious stack calling to get your data, you have to code an extra interface layer to allow Lua to build and populate your objects directly. Thanks to swiftcoder in this thread, I started using yaml-cpp and I have to say I'm a fan. Building a YAML node manually or reading data from a node are dead simple using the "new" interface, and structurally my data is very similar to a Lua table, as long as I only need data and not Lua functions-as-data.

Note that the yaml-cpp stable build is for the "old" interface which is apparently much clunkier; grab the latest build from the repository which supports syntax such as

node["x_resolution"]=1280
and
bool fullscreen=node["fullscreen"].as<bool>();
so streaming data in an out is a breeze.

Oh nice!! The old interface is what I tried last, and it certainly wasn't very friendly (and liked to spit out lots of compiler warnings). I'll have to give the new one a try, that interface looks great.

I'm always wary of downloading work-in-progress snapshots of code from a repository. Any issues that you've seen so far?

##### Share on other sites
But is richness a good thing in most use-cases? The main reason I advocate YAML over XML is it's simplicity - if you don't need schema validation, XPath, XSLT, or any of the other fancy addons to XML, it's just so much added cruft.

Exactly. Simplicity is key here. I'd use INI files if I didn't need to store other types of data than just simple values.

https://github.com/edn-format/edn is simple because it allows several data structures (lists, maps, sets), so no overloading or other wierdness is going on.

##### Share on other sites

[quote name='Nairou' timestamp='1356705245' post='5015075']
Oh nice!! The old interface is what I tried last, and it certainly wasn't very friendly (and liked to spit out lots of compiler warnings). I'll have to give the new one a try, that interface looks great.

I'm always wary of downloading work-in-progress snapshots of code from a repository. Any issues that you've seen so far?
[/quote]

So far, I haven't run into any troubles. It seems pretty stable.

##### Share on other sites

Have a look at my proposal:

http://stobml.org

It is very simple and is not overloadad with variety of special symbols, just {} and "" basically.

There is a library in C++.

##### Share on other sites

This topic is 1129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.