Json.parse (used to parse a JSON object from a String) PS: Single quotation mark written outside {}, each attribute must be double-quoted, otherwise an exception will be thrown
Let str = ' [{' field ': ' Thedate ', ' v1 ': ' 20170102 '},{' field ': ' Rev_type ', ' v1 ': ' Big Data revenue '},{' field ': ' Thismonth ', ' v1 ': ' 201708 "},{" field ":" Nextmonth "," V1 ":" 201709 "},{" field ":" Depart_type "," v1 ":" Leader "},{" field ":" admin_emp_id "," v1 ":" Role "}] ';
Json.parse (str);//str must satisfy the use of quotation marks, that is: double quotation marks and single quotation marks to each other nested
[
{field: "Thedate", v1: "20170102"},
< Span class= "object-value-string" > { field: "Rev_type", v1: "Big Data Revenue"},
< Span class= "object-value-string" > { field: "Thismonth", V1: "201708"},
< Span class= "object-value-string" > { Field: "Nextmonth", v1: " 201709 "},
< Span class= "object-value-string" > { Field: "Depart_type", v1: " Leader "},
< Span class= "object-value-string" > { Field: "admin_emp_id", v1: " role "}
]
Second, json.stringify (used to parse the string from an object)
Let arr=[
{field: "Thedate", v1: "20170102"},
{field: "Rev_type", v1: "Big Data Revenue"},
< Span class= "object-value-string" > { field: "Thismonth", V1: "201708"},
< Span class= "object-value-string" > { Field: "Nextmonth", v1: " 201709 "},
< Span class= "object-value-string" > { Field: "Depart_type", v1: " Leader "},
< Span class= "object-value-string" > { Field: "admin_emp_id", v1: " role "}
]
Json.stringify (arr);//All double quotes
"[{" Field ":" Thedate "," V1 ":" 20170102 "},{" field ":" Rev_type "," V1 ":" Big Data revenue "},{" field ":" Thismonth "," V1 ":" 201708 "},{" Field ":" Nextmonth "," V1 ":" 201709 "},{" field ":" Depart_type "," v1 ":" Leader "},{" field ":" admin_emp_id "," V1 ":" Role "}]"
Third, qs.parse () resolves the URL to the form of an object
Let URL = ' method=query_sql_dataset_data&projectid=85&apptoken=7d22e38e-5717-11e7-907b-a6006ad3dba0 '; Qs.parse (URL);//{method: "Query_sql_dataset_data", ProjectID: "$", Apptoken: "7d22e38e-5717-11e7-907b-a6006ad3dba0 "} IV, Qs.stringify () parses the object into the form of a URL let obj= {method:" Query_sql_dataset_data ", ProjectID:" $ ", Apptoken:" 7d22e38e-5717-11e7-907b-a6006ad3dba0 ", Datasetid:" 12564701 "};qs.stringify (obj)//{method:" Query_sql_dataset_data ", ProjectID:" Apptoken "," 7d22e38e-5717-11e7-907b-a6006ad3dba0 ", Datasetid:" 12564701 "}
Qs.parse (), Qs.stringify (), Json.parse (), json.stringify () How to use