I remember running across a package in the not-too-distant past which stored and retrieved data in a format similar to JSON (but not JSON). After searching some time for it today I have been unable to find it. Does anyone have any idea of what that package could be?
To be more specific, I have noticed that for my use case JSON is good but not ideal and I would like to include an additional option for users. Something ideal would be something of a cross between JSON and CSS.
Thanks!
I had not tested JLD out until now …very nice! But it’s not quite what I’m looking for. Thanks though!
We have both TOML and YAML readers. Storing data in valid CSS would be a fun project though
It sure would @MikeInnes ! Thank you for your suggestions.
CSS is somewhat terse. For example, the keys and values are not between parenthesis. Also, arrays are without brackets (Ex. margin: 0 0 3px 1px;). That makes CSS look nice, clean and readable.
Another advantage of CSS is the various metrics specifications ( %, px, em, etc ).
And having multiple keys for a given set of data is pretty cool ( html, body {…} ).
But the main drawback to CSS and the key reason that I cannot use it in my project is the lack of structure beyond a simple listing of properties. JSON allows you to nest your data however it may be needed.
Something between the two would make a nice readable file that would still be fairly compact.
1 Like
Perhaps Less or SASS? They support nesting, and you could also use mixins as a compression mechanism.
2 Likes
Thank you @MikeInnes. Those suggestions are the closest to what I’m looking for. I actually thought about them but I don’t know of anything in julia to parse or output either of them.
I may eventually end up writing something to parse SCSS-like to Dict() and be able to output the same. In the meantime I guess I may have to make due with the JSON.jl, which is very good anyways.
All of your thoughts are much appreciated Thanks!
JSON.jl can be used to help build the ability to output to an SCSS-like format already, but it’s not very well documented yet. If/when I get some time in the coming weeks, I’ll write up some documentation on how to make custom JSON-like serializers.
2 Likes
That would be great @fengyang.wang. But would it also be good for parsing it and building a dictionary similar to JSON.jl ?
For certain reasons, writing generic parsing code is quite a bit harder than generic serializing code (mostly because in serializing, you don’t have to worry about things like malformed input, different ways to write the same thing, etc.), so there is no plan at present for JSON.jl to support customized parsers.
Ok, @fengyang.wang Thank you!