Reputation: 1
Why we use json and xml for web api rather then othen platform like jquery and array. Its interview based question and I was enable to response .
Upvotes: 0
Views: 143
Reputation: 11
This is not compulsory that you have to return the result in JSON or XML, but most of the time we are returning values in these format because there are media type formatter for JSON and XML, the capability of media type formatter is to read the CLR object from HTTP message and to write the CLR object into HTTP message. This is the main reason that we return values in JSON and XML format.
Upvotes: 0
Reputation: 93
JSON and XML are ways to format and data-interchange. JQuery is a library was built on top of javascript. so it has nothing to do in data-interchange. Array by its definition: its a method for storing information. in other words you can use arrays in any format you want to store data. In Conclusion, Web API is a service that provides or gathers data. and in general you can exchange data between client and server by JSON, XML, or you can use whatever data format you want such as HTML. JQuery can be use to call the Web API that can return an array of data in any data format.
Upvotes: 1