1382Re: SV: [json] JSON representation for XML snippet
- Sep 14, 2009But one thing I didn't see mentioned was the the question of mapping
JSON arrays (it does mention use of "JSON-document” as dummy name for
outermost JSON object, which is needed). In XML there are couple of
ways of expressing logical arrays (sequences of items), so one has to
choose one from alternatives (separate container for array itself? or
for elements? or both? and what name to use for either?)
So it seems that either JSON arrays are not supported, or that details
are just not mentioned.
Also: this problem affects JSON output as well.
The the code that generates JSON output detects an array in the DOM tree and
generates a JSON array from it. The "array" are just several nodes in the tree
with the same element name that are adjacent to each other.
The JSON parsing to DOM nodes just places all the array elements adjacent to each
other in the tree with the same name. But this is an internal implementation thing that I could
do several ways. (I could add a special node in the DOM tree indicating an array
start and array end. Where these nodes are not output.)
What is in the DOM tree is not XML and not JSON and not any other format. It
is instead an intermediate format with extra "schematic" marker nodes a necessary
to indicate other information.
Another smaller issue is handling of JSON content with characters that
are legal in JSON, but illegal in XML (like control characters) is not
mentioned. Maybe such content is just passed as is; which works ok
unless app code is assuming that no such content will be received.
Well I can't discuss everything in a single article, but in the DOM tree there are
no illegal characaters since at that point its not XML. However, when you take
the DOM tree and want to output it as XML then there are standard escape/encoding
rules in XML that are used to force proper XML.
What is really nice about our approach is now I can add another plugin that takes our
ASN.1 parser (for example) and converts that into a DOM tree (since it has structure too). And then
do whatever I want to it.
-+ Tatu +-
Yahoo! Groups Links
[Non-text portions of this message have been removed]
- << Previous post in topic Next post in topic >>