Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

...

This function is not supported in SnapReduce or Spark pipelines

.

Description

Parses a string as JSON.

This is similar to the JavaScript .parse().

Note
Syntax


Code Block
JSON.parse(text)


Examples

Expression: JSON.parse("null")

Result: The string "null" is converted into the null value


ExpressionJSON.parse("[1,2,3.1,\"one\",true]")

Result: The string is converted into an array:

Code Block
 {array:{, ...}} 
      "array":  [1, 2, 3.1, one, true] 
           1, 

           2, 

           3.1, 

           "one", 

           true


...

This function is not supported in SnapReduce or Spark pipelines

.

Description

Converts a JavaScript value to a JSON string.

This is similar to the JavaScript .stringify().

Note
Syntax


Code Block
JSON.stringify(value)


Examples

Expression: JSON.stringify(null)

Result: The null value is converted into the string "null".


Expression: JSON.stringify(Date.now())

Result: The Date value is converted into a string, such as "2017-03-22T17:58:03.485Z".


Expression: JSON.stringify($array)
where $array contains [1,2,3.1,"one",true] 

Code Block
 {array:{, ...}} 
      "array":  [1, 2, 3.1, one, true] 
           1, 

           2, 

           3.1, 

           "one", 

           true


Result: The array value is converted into the string "[1,2,3.1,"one",true]".

...