New to Ada. Trying to work with some objects like the following {name:'Hermann',age:33}
in an a project and I'd rather not write my own json parser for this. Is there either:
- a way for me to configure
Gnatcolls.JSON
to parse and write these objects
or - a different library I can use with json5 or javascript object literal support?
I wrote a JSON parser from the spec pretty quickly for work while doing other things, and it took a day/day-and-a-half; it's not particularly hard and I'll see about posting it to github or something.
However, JSON5 is different enough that re-implementing it would be on the order of the same difficulty as writing some sort of adaptor. Editing the parser to accept the new constructs might be more difficult than one might anticipate, as the
IdentifierName
allowed as a key means that you can't simply chain together the sequence (1) "get-open-brace", (2) "consume-whitespace", (3) "get-a-string", (4) "consume-whitespace", (5) "get-a-colon, (6) "consume-whitespace", (7) "get-JSON-object", (8) "consume-whitespace", (9) "get-a-character; if comma, go to #1, otherwise it should be an end-brace".Perhaps one thing that makes things easier is to equate the stream- and string-operations so that you only have one production-method for your objects; there are three main ways to do this:
Make a
generic
such that it takes a string and gives the profile for the stream-operation.Make a pair of overloaded functions that provide the same interface.
Make a stream that is a string; the following does this:
With implementation of: