質問

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

役に立ちましたか?

解決

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

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top