When should we use xml in REST services and when JSON?
What are pros and cons of using json instead of XML?
This is like asking:
"what are the pros and cons of speaking french vs speaking spanish".
It depends on the context and audience for whatever you are saying.
What are the needs of your service consumers? Are you providing results to other servers or to ajax resquests from browsers? Do you have a simple object, array, or a very complex object with possibly other objects inside the main one? By providing details like that you can list pros and cons. If you can only do one, this question will drive the choice.
I typically allow the client to specify the format they want and return either json or xml. It's just 2 different 'views' or representations of the same resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With