JSON Learning Summary

Source: Internet
Author: User

The curly brace holds the object square brackets to save the array array []; object {} Array object: [{},{},{}] (1), complex JSON object. {"Employees": [{"FirstName": "John", "LastName": "Doe"}, {"FirstName": "Anna", "LastName": "Smith"}, {"FirstName": "Pete R "," LastName ":" Jones "}]," student ": {" name ":" John Johnson "," Street ":" Oslo West "," Age ": $," phone ":" 555 1234567  "}}c# code; class employees_object{empemployees[] Employees;  Student Student;      } (2), single object var jsonobject = {"Name": "John Johnson", "Street": "Oslo West", "Age": "Phone": "555 1234567"}; C # code, Class jsonobject {public string Name{get;set,} public string Street{get;set,} public string Age{get;set;} PU  Blic string Phone{get;set;} } (3), array object var employees = [{"FirstName": "John", "LastName": "Doe"}, {"FirstName": "Anna", "LastName": "Smith" }, {"FirstName": "Peter", "LastName": "Jones"},//Pay special attention to the comma here; there will be an error in the JSON online validator.  ]; Empemployees[] employees=new empemployees[]//list<empemployees> employees=new List<Empemployees> (); {New Empemployee{firstname= "JOhn ", lastname=" Doe "},new empemployee{firstname=" John ", Lastname=" Doe "},new empemployee{firstname=" John ", Lastname= "Doe"}; One of the most common uses of converting JSON text to JavaScript object JSON is to read the JSON data from the Web server (as a file or as a HttpRequest), convert the JSON data to a JavaScript object, and then This data is used in Web pages. http://www.w3cschool.cc/json/json-eval.html because JSON syntax is a subset of JavaScript syntax, the JavaScript function eval () can be used to convert JSON text to JavaScript Like. The eval () function uses the JavaScript compiler to parse the JSON text and then generate the JavaScript object. The text must be enclosed in parentheses in order to avoid syntax errors: var obj = eval ("(" + txt + ")");

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.