开发者

Which is the best way to fetch/retrieve data from server in android? Is it Xml or Json

I am trying to upload & retrieve data with the server.

Which is the best way to retrieve data us开发者_如何学Going xml or json ?

Thank you


As i have used both XML and JSON, and also used all parser including SAX, DOM, Pull Parser. I have also developed web-service for JSON and XML both.

So I suggest you to go with JSON. why? Because webservice for JSON response seems to develop easily, we don't need to do anything for creating JSON response, we just have to do json_encode() in PHP.

And while in Android, we can parse the JSON string easily by writing less code.


since it supports both.It depends on your feasibility.better go with json as it is easy to implement


I've just done an app that exchanges data over the wire with an API using Google's protocol buffers. There's a neat Java library available from Google for generating the java objects based on your proto files and other libraries to use for parsing an input stream into objects.

Really fast, very low bandwidth, though a bit of an overhead to setup and there's no readable data that you can drop into Notepad to view if you're having trouble.


IMHO the point of choosing one of them goes mainly down to the data size that needs to be transferred to the client. Obviously that should be as small as possible and so the preferred choice is usually

  • JSON
  • Google Protocol Buffers

..because they are much more concise than XML.


For data-oriented applications, I prefer JSON to XML due to its simplicity and ease of processing on the client side. XML may be great on the server side, but JSON is definitely easier to deal with on the client side.

have a look on the following url

http://www.subbu.org/blog/2006/08/json-vs-xml

Simplicity

XML is simpler than SGML, but JSON is much simpler than XML. JSON has a much smaller grammar and maps more directly onto the data structures used in modern programming languages.

Extensibility

JSON is not extensible because it does not need to be. JSON is not a document markup language, so it is not necessary to define new tags or attributes to represent data in it. Interoperability

JSON has the same interoperability potential as XML.

Openness

JSON is at least as open as XML, perhaps more so because it is not in the center of corporate/political standardization struggles.

XML is human readable

JSON is much easier for human to read than XML. It is easier to write, too. It is also easier for machines to read and write.

XML vs JSON


JSON is better then XML that's it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜