Reputation: 12876
If your REST api's data representation uses XML rather than JSON, will this aid in being able to modify the data representation without breaking the client?
For example, if today we have first name, last name in the data representation and tomorrow we add an email address to this representation, I can see that if we're using XML, all we're potentially doing is adding a new XML element which does not affect the existing elements. Clients using the "old" representation will simply disregard/skip over the new email element.
Is the same true for JSON?
Upvotes: 0
Views: 50
Reputation: 1356
Yes, the same is true for JSON as long as you are using named keys instead of numeric indexes. Imagine the following XML:
<xml>
<person>
<first_name>Person</first_name>
</person>
</xml>
This could be represented as the following JSON:
{
person: {
"first_name": "Person"
}
}
Here you can add last_name right after first_name in both snippets, and it will work fine for any client that accesses the elements by name.
Upvotes: 3