json()

Read(591) Label: json string, record, parse,

Description:

Parse a string, a record, a sequence or a table sequence of JSON format.

Syntax:

  json(x)

Note:

If parameter x is a JSON string, the function parses it into a table sequence to return; if parameter x is a record, a sequence or a table sequence, the function parses it into a JSON string to return.

The format of JSON string is [{F:v,},], where v is the value of F and a string constant should be quoted.

Parameters:

x

A JSON string/record/sequence

Options:

@v  Treat parameter x as an expression and calculate its result

Return value:

A record/sequence/table sequence/JSON string

Example:

 

A

 

1

="{name:'China',province:[{name:'Heilongjiang',cities:

{city:['Harbin','Daqing']}},{name:'Guangdong',

cities:{city:['Guangzhou','Shenzhen','Zhuhai']}},{name:'Taiwan',cities:

{city:['Taipei','Kaohsiung']}},{name:'Xinjiang',cities:{city:['Urumqi']}}]} "

 

2

=json(A1)

A1 is a JSON string, which is parsed into a table sequence and return the result:

3

=demo.query("select EID,NAME,SURNAME from EMPLOYEE")

4

=json(A3)

A3 is a table sequence, which is parsed into a JSON string and return the result: