JSON in JavaScript Asp.net, jsonasp.net

Source: Internet
Author: User

JSON in JavaScript Asp.net, jsonasp.net

First official website http://www.json.org/js.html

Download json2.js to Github download https://github.com/douglascrockford/JSON-js

The background defines and generates json and returns to the foreground


Here we make a simple return in the background (in AbnormalCustomerList. ashx. cs)

String stbList = "{\" Rows \":[";
StbList = stbList + "{\" id \ ": 1, \" name \ ": \" Lin San \ ", \" sex \ ": \" male \", \ "birthday \": \ "1989/01/12 \"},";
StbList = stbList + "{\" id \ ": 2, \" name \ ": \" Zhang Wu \ ", \" sex \ ": \" male \", \ "birthday \": \ "1986/11/24 \"}";
StbList = stbList + "],";
StbList = stbList + "\" Count \ ": [{\" total \ ": 2}]"; // records a total of several data records returned
StbList = stbList + "}";

Context. Response. Write (stbList. ToString ());

 

Foreground reference

Var varReceiver = JSON. parse (e. result );
// Alert (varReceiver. Rows [0]. name)
For (var I = 0; I <varReceiver. Count [0]. total; I ++)
{
Alert (varReceiver. Rows [I]. name)
}

At alert, Popup will be followed to get Lin sanzhang Wu.

In addition: JSON. parse () and JSON. stringify () Usage

Http://blog.csdn.net/wangxiaohu__/article/details/7254598

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.