jsParse

Creates a JSON container from a JSON data string.

Syntax:

jsParse ( json-text )

Parameters:

(s) json-text: JSON data represented as a text string.

Returns:

(a) json-container: A JSON extender handle to a JSON container. 

JsParse converts a text representation of JSON data into a JSON container handle. JSON container handles are unique identifiers use by the extender to store and track JSON data as key/value pairs and array elements. JSON handles are used by other extender functions to query, modify, and convert the JSON data the handle represents.

 

Json-Text

This parameter must contain a valid text representation of JavaScript Object Notation (JSON) data conforming to a subset of the JavaScript Programming Language (Standard ECMA-262).  You can source the string  from a Website response, a file, or, as in the example below, a manifest constant string value.

  

  

Example:
  AddExtender('ilcjs44i.dll', 0, 'ilcjs64i.dll')
  
  ; JSON data example from a Website.
  Text = $" {
     "Orders":: [
        {
           "Order":: {
              "Number":: "IO12340",
              "Date":: "2021-05-31T00::00::00"
           },
           "AccountNumber":: "WC29825",
           "Item":: {
              "Price":: 2010.98,
              "Quantity":: 1
           }
        },
        {
           "Order":: {
              "Number":: "IO11345",
              "Date":: "2019-06-01T00::00::00"
           },
           "AccountNumber":: "WC73565",
           "Item":: {
              "Price":: 2017.994,
              "Quantity":: 3
           }
        }
     ]
  }$"
  
  ; Load the JSON data into the extender.
  Object = jsParse(Text)
  ; Get the paths to the Quantity key.
  Paths = jsKeyPaths(Object, 'Quantity')
  ; Sum quantities.
  Total = 0
  ForEach path In Paths
     Total += jsValueGet(Object, Path)
  Next
  Pause('Total Items Sold', Total)
  
  ; Don't forget to clean up.
  jsConClose(Object)
  
See Also:

jsKeyPaths, jsValueType, jsValueGet