zoukankan      html  css  js  c++  java
  • JavaScript Object Notation (JSON)

    JSON, short for JavaScript Object Notation, is a lightweight computer data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays (called objects).
    The JSON format is often used for serialization, transmitting structured data over a network connection. Its main application is in Ajax web application programming, where it serves as an alternative to the use of the XML format.
    Although JSON was based on a subset of the JavaScript programming language and is commonly used with that language, it is considered to be a language-independent data format. Code for parsing and generating JSON data is readily available for a large variety of programming languages. The json.org website provides a comprehensive listing of existing JSON bindings, organized by language.

    JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

    JSON is built on two structures:

    • 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.
    • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

    These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.

    JSON in C#

    System.Runtime.Serialization.Json Namespace
    this namespace contains classes thant can be used for serializing objects to JSON and deserializing objects from JSON.
    DataContractJsonSerializer:Serializes objects to the JavaScript Object Notation (JSON) and deserializes JSON data to objects. This class cannot be inherited.
          ReadObject:  Deserializes JSON (JavaScript Object Notation) data and returns the deserialized object.  
          WriteObject:  Serializes an object to a JavaScript Object Notation (JSON) document.
    JsonReaderWriterFactory: Produces instances of XmlDictionaryReader that can read data encoded with JavaScript Object Notation (JSON) from a stream or buffer and map it to an XML Infoset and instances of XmlDictionaryWriter that can map an XML Infoset to JSON and write JSON-encoded data to a stream. 
    Remarks: Windows Communication Foundation (WCF) processes JSON messages using a mapping between JSON data and the XML Infoset. Normally, this mapping is hidden from view. However, in some advanced scenarios it may be necessary to manually convert between JSON and XML. In this case, the JsonReaderWriterFactory class can be used to create the necessary XML readers and writers. Note that not every XML Infoset element can be mapped to JSON. For more information about mapping, see JSON Serialization.

    System.Json Namespace

    The System.Json namespace provides standards-based support for the serialization of JavaScript Object Notation (JSON).


    Ref:
    1. json.org
    2. http://en.wikipedia.org/wiki/JSON
  • 相关阅读:
    奋力拼搏,永不言弃
    软件工程最终总结
    人生第一次JAVA编程,电梯(并不算完成版),以及IDEA里使用git
    尝试单元测试
    作业2的回答
    word count程序,以及困扰人的宽字符与字符
    关于未成品的问题:字符类型和其他种种
    随手一写,简单的四则运算练习
    浏览器缓存分析
    Codeforces Round #582 (Div. 3)
  • 原文地址:https://www.cnblogs.com/whyandinside/p/1541126.html
Copyright © 2011-2022 走看看