E-commerce user behavior analysis of Spark project Big Data Platform (11) JSON and Fastjson

Source: Internet
Author: User

I. Overview

The full name of JSON is "JavaScript Object Notation", which means the JavaScript objects notation, which is a text-based, language-independent, lightweight data interchange format. XML is also a data interchange format, why not choose XML? Since XML can be used as a cross-platform data interchange format, it is very inconvenient to process XML in JS (abbreviated JavaScript), while XML tags are much more than data, which increases the traffic generated by the interchange, and JSON does not have any tags attached to it, which can be treated as objects in JS. So we are more inclined to choose JSON to exchange data. This article explains JSON mainly from the following aspects.

II. structure of JSON 2.1 simple values

Simple values use the same syntax as JavaScript to represent strings, numeric values, Booleans, and Null in JSON

The string must be in double quotation marks and cannot use single quotation marks. Values must be expressed in decimal, and Nan and infinity cannot be used

Note JSON does not support special values in JavaScript undefined

// Pass-through simple values 5 " Hello World " true NULL
// unqualified Simple value +0x1'helloworld'undefinednaninfinity

2.2 Objects

An object is a complex data type that represents an ordered set of key-value pairs. The value of each key-value pair can be a simple value, or it can be a value of a complex data type (where the keyword is a string, and the value can be a string, a value, a true,false,null, an object, or an array)

JSON has three different places compared to the object literals of JavaScript

1, JSON does not have the concept of variables

2. In JSON, the key name of the object must be enclosed in double quotation marks

3, because JSON is not a JavaScript statement, so there is no end of the semicolon

[note] Two properties with the same name should not appear in the same object

//Eligible Objects{    "name":"Huochai",    " Age": in,    "School":{        "name":"Diankeyuan",        " Location":"Beijing"    }}
//non-conforming objects{Name:"Zhang San",' Age': +}//property names must use double quotation marks{};//do not need a semicolon at the end{"Birthday":NewDate ('Fri, 07:13:10 GMT'),  "GetName": Function () {return  This. Name; }} //function and date objects cannot be used

2.3 Arrays

An array is also a complex data type that represents a list of ordered sets of values that can be accessed by a numeric index. The value of an array can also be any type-simple value, object, or array

JSON arrays also have no variables and semicolons, which combine arrays and objects to form more complex collections of data

[note] After the last member of an array or object, you cannot add commas

[    {        key1:value1,        key2:value2     },    {         key3:value3,         key4:value4       }]

Three, JSON detailed

Https://www.cnblogs.com/passer00/p/6088925.html

Iv. Fastjson

Https://www.cnblogs.com/cdf-opensource-007/p/7106018.html

E-commerce user behavior analysis of Spark project Big Data Platform (11) JSON and Fastjson

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.