util.JSONObject.parse
Parses a JSON string and creates a JSON object from it.
Syntax
util.JSONObject.parse(
s STRING )
RETURNS util.JSONObject
- s is a string value that contains JSON formatted data.
Usage
The util.JSONObject.parse()
method scans the JSON source string
passed as parameter and creates a JSON object from it.
The created object must be assigned to a program variable defined with the
util.JSONObject
type.
The source string must follow the JSON format specification. It can contain multi-level structured data, but it must start with a curly brace.
The method raises error -8109 if the JSON source string is not properly formatted. Consider enclosing the
parse()
method call in a TRY/CATCH
block, if the source string can
be malformed JSON.
Example
IMPORT util
MAIN
DEFINE js STRING
DEFINE obj util.JSONObject
LET js='{ "cust_num":2735, "cust_name":"McCarlson",
"orderids":[234,3456,24656,34561] }'
LET obj = util.JSONObject.parse( js )
DISPLAY obj.get("cust_name")
END MAIN