Xml and json

Source: Internet
Author: User

 

XML: easy to expand and redundant.

It is represented by <>. As shown in:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper  namespace="zhuxuekui.data.UserMapper">
        <resultMap id="userResultMap"  type="User">
            <result property="name" column="username"></result>
            <result property="email" column="email"></result>
        </resultMap>        
        
        <select id="selectUser" parameterType="String"
            resultMap="userResultMap">
            select 
            *
            from user where username = #{username}
        </select>
        
    </mapper>

JSON: it is not easy to expand, but has little redundancy and lightweight development.

Reference: http://www.cnblogs.com/mydomain/archive/2010/12/02/1895018.html JSON basics Summary

Http://www.cnblogs.com/mydomain/archive/2010/12/02/1895030.html

An object is an unordered set of 'name/value' pairs. An object starts with "{" (left parenthesis) and ends with "}" (right Parenthesis. Each "name" is followed by a ":" (colon); "," (comma) is used to separate the "name/value" pairs. [7]

An array is an ordered set of values. An array starts with "[" (left square brackets) and ends with "]" (right square brackets. Values are separated by commas.

Value can be a string, number, true, false, null, object, or array enclosed by double quotation marks ). These structures can be nested.

A string is a collection of any number of Unicode characters enclosed by double quotes. It is escaped using a backslash. A character (character) is a separate string (character string ). A string is very similar to a C or Java string.

Although a JSON string is called a string, its full process is called JavaScript Object Notation-JavaScript Object Notation. This string is parsed as an Object in js, And it is syntax-level. Intra-row blocking is required.

{} Is an object with many attributes. [] Indicates an array. There can be two objects, so you can write one.

{} Can also contain [], which indicates multiple objects.

We can think that http is a network protocol, while JSON is a data protocol, which is used for data transmission.

The above is xml, and the following is json:

String, number, object, array, true, false, null

JSON
{"menu": {
"id": "file",
"value": "File:",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}
}
XML
<menu id="file" value="File" >
<popup>
<menuitem value="New" onclick="CreateNewDoc()" />
<menuitem value="Open" onclick="OpenDoc()" />
<menuitem value="Close" onclick="CloseDoc()" />
</popup>
</menu>

Related Article

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.