Before implementing RESTFul Web Service in WCF (1): basic concepts of JSON

Source: Internet
Author: User

Basic concepts of JSON:
WIKIPEDIA: JSON (JavaScript Object Notation), is a lightweight text-based open standard designed for human-readable data interchange. it is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. despite its relationship to JavaScript, it is language-independent, with parsers available for most ages.
The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML.

JSON is a lightweight data exchange format. Easy for reading and writing, and easy for machine parsing and generation. JSON uses a language-independent text format, but it also uses a style similar to the C language family (including C, C ++, C #, Java, and JavaScript ). These features make JSON an ideal data exchange language. Many languages or libraries provide excellent support for JSON format and facilitate various parsing and operations.

 

JSON is based on two structures:
1. A collection of name/value pairs. In various versions, this is realized as an object, record, struct, Dictionary, hash table, keyed list, or associative array.
2. An ordered list of values. In most ages, this is realized as an array, vector, list, or sequence.

 

JSON format rules:
Number (type not specified, but in practice Double Precision Floating-point format, as this is how Javascript in Web browsers treats it)
String (double-quoted Unicode (UTF-8 by default), with backslash escaping)
Boolean (true or false)
Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
Object (an unordered collection of key: value pairs with the ': 'character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and shoshould be distinct from each other)
Null (empty)

 

Example of JSON format data:
The following example shows the JSON representation of an object that describes a person. the object has string fields for first name and last name, a number field for age, contains an object representing the person's address, and contains a list (an array) of phone number objects.

JSON Sample

{
"firstName": "John",
"lastName" : "Smith",
"age" : 25,
"address" :
{
"streetAddress": "21 2nd Street",
"city" : "New York",
"state" : "NY",
"postalCode" : "10021"
},
"phoneNumber":
[
{
"type" : "home",
"number": "212 555-1234"
},
{
"type" : "fax",
"number": "646 555-4567"
}
]
}

 

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.