With the exception of needing an XML file, is there a benefit to using XML over JSON? JSON seems like an easier way to handle a return but I have very little experience using one or the other
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I recommend JSON over XML when doing Ajax. Why? Because a JavaScript engine can easily turn that JSON response into a JavaScript object… allowing you to access/manipulate that data very easily. You just have to use
eval()orJSON.parse()or something similar (depending on the browser/javascript library).JSON is valid JavaScript; so on the whole it meshes much better with Ajax/Javascript/Web than XML does.
JSON also tends to be a bit less verbose, especially in regards to arrays and key/value pairs… something you are likely to be encountering a lot with web services.
With XML people tend to create their own specialized XML vocabulary. So if anyone wanted to use your services, they’d also have to learn your XML vocab. JSON is much more universal in this regard.