The format description of JSON can be seen here, in very detail, or in Chinese.
JSON Format Description
It is particularly noteworthy that property names in JSON are enclosed in quotes.
Using JSON in JQuery
jquery is a widely used script library now, so how do you use JSON
script to make it easier to format the output when using a data table that queries JSON that already has a fixed schema. Example I used SQL Server worldwide Importers sample database, which can be downloaded directly on GitHub (). Take a look at the view website.customers. we query a data and format the output JSON format:SELECT [CustomerID] , [CustomerName
JSON(JavaScript Object Notation) is a lightweight data exchange format. Easy to read and write. It is also easy to parse and generate machines. It is based on a subset of JavaScript programming language, standard ECMA-262 3rd edition-December 1999. JSON uses a completely language-independent text format, but it also uses a habit similar to the C language family (
")}}
Outputs:
Name is string Wednesday
Age was of a type I don ' t know how to handle
parents is an array:
0 Gomez
1 Moticia
As you can see from the example above, we can parse the JSON function of the unknown structure by interface{} with the type Assert.
Generate JSON
if we want to output a JSON data string, we can
' t know how to handleparents is an array:0 Gomez1 MoticiaAs you can see from the example above, we can parse the JSON function of the unknown structure by interface{} with the type Assert. Generate JSONif we want to output a JSON data string, we can use the marshal function to handleFunc Marshal (v interface{}) ([]byte, error)Example:Generaljsonpackage mainimpo
JSON is the syntax for storing and exchanging textual information. Similar to XML.JSON is smaller, faster, and easier to parse than XML.What is JSON? JSON refers to JavaScript Object notation (JavaScript Object Notation), JSON is a lightweight text data Interchange Format, JSON
What is JSON?
JSON refers to the JavaScript object notation (JAvaScript Object Notation)
JSON is a lightweight text data interchange Format
JSON independent of language
JSON is self-descriptive and easier to understand
*
C + + parsing json (JSONCPP)JSON(JavaScript Object Notation)is a lightweight data interchange format. It is based on a subset of JavaScript (standard ECMA-262 3rd edition-december 1999). JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl, Python, etc.). These feat
small part of the data, we can consider using Linq to JSON to read and modify part of the data instead of deserializing all.
2. Json. Net not only supports serialization and deserialization of objects, but also supports conversion between XML and JSON. It supports conversion between data types and JSON, such as DataSe
brackets. Values are separated by commas. Its structure 2 is shown in.
Figure 2 JSON Array Structure
The following code is a simple JSON array example:
["Beijing", "Shanghai", "Guangzhou"]
Type of 1.3 Value
In the JSON object and array structure, the value can not only be a simple data type such as a number or string, but also an object or an arr
string, which is also a string retsrc = entityutils stored in JSON format. tostring (httpresponse. getentity (); // generate JSON object jsonobject result = new jsonobject (retsrc); string token = result. get ("token ");
The following is a small example of modifying others by yourself. It mainly adds some comments and explanations. This example mainly uses Andro
: BeijingStreet: Chaoyang RoadPostcode: 100025 (integer)
JSON format:
{ Quot; City quot;: quot; Beijing quot;, quot; Street quot;: quot; Chaoyang Road quot;, quot; postcode quot;: 100025}
Value can also be another object or array. Therefore, a complex object can be nested. For example, a person object contains the name and address objects, which can be expressed as follows:
{"Name": "Mic
() methods can both return the specified value through the index, and the put () method is used to add or replace the value. The value Type of this class can also include: Boolean, JSONArray, JSONObject, Number, String, or the default value JSONObject. NULL object.JSONTokener: json parsing classJSONException: Exceptions in json1. Construct jsonFirst, we will build a simple json//
These inputs need to be written to the database. Here json is used for input. Let's take a look at how the data to be transmitted is generated in the background. If you are interested, refer, I hope this will help you write the previous blog and use javascript to generate multiple groups of texts, so that data input is not displayed. Now we need to write these inputs into the database. Here we will use
convert to XML, you need to generate node properties, #text则为节点的内容. The conversion here is a common practice for commonly used converters.The following conversion examplesXml:Convert to JSON{" Student": { "@ID": "1001", "#text": "Zhang San" }}3) node-generated object with attributesExample 1, no attribute node, simple string arrayConvert to JSON:{"Line
is a standard JSON request implementation process:
HttpPost request = new HttpPost (URL);
First encapsulates a JSON object
jsonobject param = new Jsonobject ();
Param.put ("name", "Rarnu");
Param.put ("Password", "123456");
Bind to request Entry
stringentity se = new stringentity (param.tostring ());
Request.setentity (SE);
Send Request
HttpResponse HttpResponse = new Defaulthttp
parse, client JavaScript can simply read JSON data via eval ();C. Support multiple languages, including ActionScript, C, C #, ColdFusion, Java, JavaScript, Perl, PHP, Python, Ruby and other server-side languages, easy server-side resolution;D. In the PHP world, there have been Php-json and json-php appeared, biased in PHP after the serialization of the program d
an ordered collection of values (value). An array begins with "[" (left bracket), and "]" (right bracket) ends. Values are separated from each other by using the "," (comma). The schematic diagram of the structure is shown in Figure 2.
Figure 2 schematic diagram of the JSON array structure
The following code is a simple example of a JSON array:
["Beijing", "Shanghai", "Guangzhou"]
1.3 Types of values
times faster than XML! When Ajax is treated as a desktop application, speed is the most important factor. Obviously, JSON is better.
Of course, you cannot always control the server to generate data for Ajax programs. You can also use a third-party server to provide XML output instead of the server. In addition, if the server exactly provides JSON, are you sure y
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.