|
Boost Users : |
Subject: [Boost-users] How strong is PropertyTree JSON support
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2019-01-08 17:50:52
Hello,
I have a requirement to support parsing JSON, and while I could
potentially pull together a Spirit Qi (or even X3, possibly) based
grammar, I wonder with all the idiosyncrasies, i.e. particularly
strings, escape sequences, Unicode, etc, is it worth it.
Then there's the Boost.PropertyTree JSON support, which I think may be
an adequate fit. However, just how robust is this support when it
comes to handling some of the nuanced corner cases? The harder ones I
think are the potential for escape sequences, Unicode, etc, embedded
within a String.
i.e. https://json.org/
or, http://es5.github.io/x7.html
It seems with Property Tree there are also these limitations:
<docs>
The property tree dataset is not typed, and does not support arrays as
such. Thus, the following JSON / property tree mapping is used:
* JSON objects are mapped to nodes. Each property is a child node.
* JSON arrays are mapped to nodes. Each element is a child node with
an empty name. If a node has both named and unnamed child nodes, it
cannot be mapped to a JSON representation.
* JSON values are mapped to nodes containing the value. However, all
type information is lost; numbers, as well as the literals "null",
"true" and "false" are simply mapped to their string form.
* Property tree nodes containing both child nodes and data cannot be mapped.
</docs>
It seems to me that much of the limitation is in adapting the
PropertyTree to the JSON structure, but mostly vice versa. Not quite
fitting a square peg in a round hole, but coming quite close, I think:
"If a node has both named and unnamed child nodes, it cannot be mapped
to a JSON representation." We're talking about the mapping from
PropertyTree to JSON here?
Seems like a potentially problematic issue depending on desired usage,
'all type information is lost; numbers, as well as the literals
"null", "true" and "false" are simply mapped to their string form'.
I'm not sure what "nodes containing both child nodes and data" means?
Besides these concerns, I should think a grammar is fairly
straightforward to construct, if push came to shove. It's either
living with the Boost.PropertyTree or rolling my own AST, which is not
outside the realm of possibility for my purposes.
Thoughts? Suggestions?
Thanks!
Michael Powell
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net