Java network communication--xml and JSON

Source: Internet
Author: User
XML (extensible Markup Language)

Definition: An extensible, markup language

XML has a wealth of coding tools, such as dom4j, Jdom, and so on.

JSON (JavaScript Object Notation)

Definition: A lightweight format for data interchange

JSON also has the tools provided by json.org, but JSON is much easier to encode than XML, and even if you can write JSON code without tools, it's not easy to write XML.

Comparison of the two

Parsing method

XML currently has two ways of parsing: Dom and sax.

DOM: The XML as a whole as an object, parsing the time to read the entire XML into memory.

Sax:sax does not need to read the entire document can be parsed out of the content of processing, is a step-by-phase analysis method. The program can also terminate parsing at any time. In this way, a large document can be gradually and 1.1 points, so sax is suitable for large-scale parsing. At this point, JSON is not available at this time.

JSON parsing is much more convenient, he is key/value; can be seen as an array.

Encoding: XML easy to read and hard to write JSON easy to write difficult to read

  

Java network communication--xml and JSON

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.