Alternative to JSON and XML?

Started by
29 comments, last by ApochPiQ 9 years, 4 months ago
Wanted to second/third YAML.
Otherwise you're back to .ini files or roll-your-own.

PS LiquidXML is an awesome tool for XML schema creation. I used it through beta to release.
LiquidXML would be most useful with C# or maybe Java; don't think it'd help much with C code.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement

Another one, a more human friendly version of JSON perhaps:

http://bitsquid.blogspot.de/2009/10/simplified-json-notation.html

Just as with any customized format you would have to convert it if you need to use it inside another application.

https://github.com/edn-format/edn is a nicer and richer format than JSON and XML. If there is some kind of library that deals with it in C++ or whatever, you should try it.

https://github.com/edn-format/edn is a nicer and richer format than JSON and XML. If there is some kind of library that deals with it in C++ or whatever, you should try it.
It's richer than JSON, at any rate. Doesn't look nearly as rich as XML...

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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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.

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.

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

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?

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.

[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.

This topic is closed to new replies.

Advertisement