When to use Xml and when to use JSON

 

XML

JSON

You need message validation

You don't need Messages to be validated

XML transfer is slower then JSON since the file size is relatively compared to JSON.

JSON is a good if you want to transmit data faster from client to server, due to reduced file size

You need to transform the XML i.e. if  using XSLT

You're not transforming messages, or transforming their de serialization is simple

Your messages include a lot of marked-up text

Your messages are mostly data, not marked-up text

You need to interoperate with environments that don't support JSON

The messaging endpoints have good JSON tools

Used when objective is to carry or store data

Used when objective is to display the Data

When there is no concern for reduced file/transfer size.

When there is a requirement for reduced file/transfer size.

Processing is slower since XML has to be parsed with XML parser.

Processing is faster since JSON can be parsed by a standard JavaScript function.

 

No comments: