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

转载于:https://www.cnblogs.com/whyandinside/archive/2009/08/07/1541126.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值