JSON or SOAP (XML)?

后端 未结 7 1389
清歌不尽
清歌不尽 2020-12-04 19:05

I\'m developing a new application for the company. The application have to exchange data from and to iPhone.

Company server side uses .NET framework.

For ex

7条回答
  •  天涯浪人
    2020-12-04 19:49

    JSON has following advantages:

    1. it can encode boolean and numeric values ... in XML everything is a string
    2. it has much clearer semantics ... in json you have {"key":"someValue"}, in XML you can have someValue or ... any XML node must have a name ... this does not always make sense ... and children may either represent properties of an object, or children, which when occuring multiple times actually represent an array ... to really understand the object structure of an XML message, you need its corresponding schema ... in JSON, you need the JSON only ...
    3. smaller and thus uses less bandwidth and memory during parsing/generation ...

    apart from that, i see NO difference between XML and JSON ... i mean, this is so interchangable ... you can use JSON to capture the semantics of SOAP, if you want to ... it's just that SOAP is so bloated ... if you do want to use SOAP, use a library and generators for that ... it's neither fun nor interesting to build it all by hand ...

    using XML RPC or JSON RPC should work faster ... it is more lightweight, and you use JSON or XML at will ... but when creating client<->server apps, a very important thing in my eyes, is to abstract the transport layer on both sides ... your whole business logic etc. should in no way depend on more than a tiny interface, when it comes to communication, and then you can plug in protocols into your app, as needed ...

提交回复
热议问题