|
|
|
|
|
by Matt3o12_
3171 days ago
|
|
I believe that was OP's point. Using the annotation you cannot add an attribute with subattributes. What if you wanted to add the employee's last six salaries. Suddenly you need to restructure your xml: <employees>
<employee>
<name>John Crichton</name>
<gender>male</gender>
<salaries>
<salary>10000</salary>
<salary>10000</salary>
<salary>10000</salary>
<salaries>
</employee>
<employee>
<name>Aeryn Sun</name>
<gender>female</gender>
</employee>
</employees>
Using JSON, you just so: “salaries”: [10000,10000,10000]JSON is not only less verbose, it is also more flexible and easier to read and understand. You don’t have to worry about should I use tags or attributes for that because I late might have to use sub tags, and that makes it far easier to use (and honestly parse as well because many XML documents I have gotten are very inconsistent). |
|
Using a List (XSD List) type:
And using mixed content (complexType):