JSON extension application based on ASP.net 3.5 Web service

Source: Internet
Author: User
Tags hash http post soap json

If you often use ASP.net Web services, then you know that they can communicate in different ways. asp.net Web services can be invoked using some of the supported protocols of the SOAP 1.1/1.2,http Post and HTTP get. We can easily invoke Web services via HTTP POST or get, and also have the ability to deliver information and receive short JSON-encoded objects instead of using normal string and XML delivery.

JSON (JavaScript Object notation) is a lightweight data interchange format that takes a completely language-independent text format and replaces XML as a number interchange format in an AJAX program. It is similar to XML and SOAP, and also has Cross-platform features, is based on a subset of JavaScript, and easy to read and write, but also easy to machine parsing and generation. It also uses a family of C-language (c, C + +, C #, Java, JavaScript, Perl, Python, etc.) that makes JSON the ideal data exchange language. Microsoft chooses JSON to exchange data between server and AJAX clients. A (data) serializer and parallelization are implemented on both the client and server side to enable data to be exchanged in JSON format. This provides a way for the browser to send a Web service request to the server. At the same time, it also provides an asynchronous communication layer, which connects the browser with the network terminal. The Microsoft.Web.Script.Services namespace provides support for Ajax to fully describe the data transferred between the server and the client in JSON format, starting with the beta version.

Although there is a lot of publicity about how XML has cross-platform, Cross-language advantages, however, unless applied to web Services, developers often have a brain for XML parsing in ordinary Web applications, whether it's server-side generation or processing XML, or client JavaScript parsing XML, often leads to complex code, very low development efficiency. In fact, for most Web applications, they do not need complex XML to transmit data, XML extensibility has little advantage, and many AJAX applications even directly return HTML fragments to build dynamic Web pages. As opposed to returning XML and parsing it, returning HTML fragments greatly reduces the complexity of the system, but at the same time lacks some flexibility.

Now, JSON provides another form of data interchange for Web application developers. Let's see what JSON is. JSON provides better simplicity and flexibility than XML or HTML fragments. JSON data format parsing is the same as XML, and JSON is based on plain text data format. Because JSON is inherently prepared for JavaScript, JSON's data format is very simple, you can transfer a simple string,number,boolean with JSON, or you can transfer an array or a complex object.

It has two kinds of structures:

1, the collection of name/value pairs (A collection of name/value pairs). In different languages, it is understood as objects (object), records (record), structure (struct), dictionaries (dictionary), hash tables (hash table), a list of keys (keyed list), or associative arrays (associative Array).

2, the value of the sequence table (an ordered list of values). In most languages, it is understood as an array. Let's take a look at the following XML representation:

<posts>

<post>

<id>1</id>

<title> title 1</title>

<content> content </content>

<posterId>12</posterId>

</post>

<pos t>

<id>2</id>

<title> title 2</title>

<content> content </con tent>

<posterId>13</posterId>

</post>

</posts>

Related Article

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.