Both JSON and XML can be used to receive data from a web server.
JSON = XML
- Both JSON and XML are “self describing” (human readable)
- Both JSON and XML are hierarchical (values within values)
- Both JSON and XML can be parsed and used by lots of programming languages
- Both JSON and XML can be fetched with an XMLHttpRequest
JSON != XML
- JSON doesn’t use end tag
- JSON is shorter
- JSON is quicker to read and write
- JSON can use arrays
I will recommend to use JSON why? because it is parsed into a ready-to-use JavaScript object. XML on the other hand is difficult.