zoukankan      html  css  js  c++  java
  • 写在WCF实现RESTFul Web Service之前(一):JSON基本概念

    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 languages.
    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是一种轻量级的数据交换格式。易于人阅读和编写,也易于机器解析和生成。JSON采用独立于语言的文本格式,但是也使用了类似C语言家族的习惯(包括C, C++, C#, Java, JavaScript等)。这些特性使JSON成为理想的数据交换语言。很多语言或库对JSON格式有非常好的支持,能方便的进行各种解析和操作。

    JSON基于两种结构:
    1. A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
    2. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

    JSON支持的格式规则:
    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 should be distinct from each other)
    null       (empty)

    JSON格式数据举例:
    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"
    }
    ]
    }
  • 相关阅读:
    Comet OJ 夏季欢乐赛 篮球校赛
    USACO Tractor
    Comet OJ 夏季欢乐赛 Gree的心房
    USACO Hide and Seek
    Comet OJ 夏季欢乐赛 分配学号
    php如何上传txt文件,并且读取txt文件
    插入多行数据的时候,一个insert插入多行
    连接优化查询,按条件查询的时候,如何优化查询的时间
    如何将txt的多行记录直接导入到mysql数据库
    如何在自己的网页上插入一个超链接,发起临时qq会话
  • 原文地址:https://www.cnblogs.com/KeithWang/p/2342995.html
Copyright © 2011-2022 走看看