JPARSE() |
|
|
The JPARSE() function parses a JSON string into a data collection.
Format
JPARSE(var) JPARSE(var, mode)
where
The JPARSE() function transforms a JSON (JavaScript Object Notation) string into a data collection variable. If successful, the return value of the function is a data collection and the STATUS() function returns zero.
JPARSE() treats spaces, tabs, carriage returns, linefeed and all five mark characters as whitespace, ignoring them between JSON elements.
If the JPARSE() function fails, a null string is returned and the STATUS() function returns a non-zero error code. The INMAT() function will return the character position in the JSON string at which the error was detected.
Example
VAR = JPARSE(JSON.STRING) VAR{'client/name'} = NEW.CLIENT.NAME JSON.STRING = JBUILD(VAR)
The above program fragment parses a JSON string into a data collection variable, modifies the client name element and rebuilds the JSON representation of the modified data.
See also: |