与可变格式的纯字符串相比,使用JSON/XML有什么优势? [英] What are advantages of using JSON/XML over a plain string of variable format?
问题描述
相对于可变格式的纯字符串,使用JSON/XML有什么优势?
What are advantages of using JSON/XML over a plain string of variable format?
我们有一个iPhone应用程序,在该应用程序中,我们接收到一串变量作为对我们对url的帖子的响应,而不是使用服务器上的JSON/XML.
We have an iPhone application where we are receiving a string of variables as a response to our post to an url rather then using JSON/XML from the server.
以JSON/XML传递数据对我们有什么好处?
What would be some of the advantages to us being passed the data in JSON/XML?
推荐答案
JSON支持传输结构化数据,而您不必解析客户端.
JSON enables the transmission of structured data, that you don't have to parse client side.
当您有一个使用这些数据来构建/填充界面的html/js客户端时,这很有用,因为数据会自动以您在js代码中所需的格式显示.
It's useful when you have an html/js client which uses those data to build/fill the interface, as the data are automatically in the format you'll need in your js code.
在服务器端,由于所有主要语言现在都具有高效的库,因此也很容易进行编码/解码.
Server side, it's easy to encode/decode too, as all major languages now have efficient libraries.
首选JSON而不是XML,因为它既易于阅读,又更轻便.
Prefer JSON over XML as it is both more human readable and lighter.
这篇关于与可变格式的纯字符串相比,使用JSON/XML有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!