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"
    }
    ]
    }
  • 相关阅读:
    团队编程规范
    软工小组:我们都是水果
    Github与SmartGit使用说明与建议
    Github for Windows使用图文教程
    SQL语句实现mysql数据库快速插入1000w条数据
    dijkstra+relax修改
    Kuchiguse (20)简单字符串处理,输入坑
    1098. Insertion or Heap Sort (25)堆排序
    Consecutive Factors(求n的连续约数)
    Dijkstra(第二关键词最优),路径保存DFS
  • 原文地址:https://www.cnblogs.com/KeithWang/p/2342995.html
Copyright © 2011-2022 走看看