parse_json
| Definition: |
include builtins\json.e
object res = parse_json(string s) |
| Description: |
Converts a string representation of a JSON object into an internal form suitable for further processing.
s: should contain a valid string representation of a JSON object. |
| pwa/p2js: | Supported. |
| Notes: |
The result of parsing a JSON string is as follows:
For some more valid (and invalid) JSON examples, see demo\rosetta\JSON.exw. Attempts to parse an invalid JSON string yield {JSON_INVALID}, ie {-4}. |
| Example 1: |
include builtins\json.e
string str = `{"this":"that","age":29}`
object res = parse_json(str)
-- res is {JSON_OBJECT,{"this","that"},{"age",29}}
|
| Example 2: |
-- note that parse_json() is non-thread-safe, -- without suitable protection such as the following: include builtins\json.e ... integer json = init_cs() ... enter_cs(json) res = parse_json(src) leave_cs(json) |
| See Also: | print_json |