Question

I have an information system to which we can pose queries in XML like this:

<Query>
<Condition>
...
</Condition>
<LogicalOperator>AND</LogicalOperator>
<Condition>
...
</Condition>
<LogicalOperator>AND</LogicalOperator>
<Condition>
...
</Condition>
</Query>

This sibling order is imporant and enforced by schematron (LogicalOperator between Condition).

How can I represent this data in JSON, preserving its semantic? The JSON becomes something like

"Query": {
    "Condition": [{...},{...},{...}]  ,
    "LogicalOperator": ["AND","AND"]
}

And a lot of semantic information is lost. How can I encode all this information in JSON

Was it helpful?

Solution

"Query": [{...},"AND",{...},"AND",{...}] 

Deserialize with gson using the mixed-type-collection recipe and serialize with jaxb

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top