Qore JSON Module  1.4
 All Classes Namespaces Functions Groups
JSON Functions

Functions

string Qore::Json::makeFormattedJSONString (any data, *string encoding)
 Serializes qore data into a JSON string, formatted with line breaks for easier readability. More...
 
string Qore::Json::makeJSONString (any data, *string encoding)
 Serializes qore data into a JSON string, without any line breaks. More...
 
nothing Qore::Json::parseJSON ()
 This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters. More...
 
any Qore::Json::parseJSON (string json_str)
 Parses a JSON string and returns the corresponding Qore data structure. More...
 

Detailed Description

Function Documentation

string Qore::Json::makeFormattedJSONString ( any  data,
*string  encoding 
)

Serializes qore data into a JSON string, formatted with line breaks for easier readability.

By default the string produced will be in UTF-8 encoding, but this can be overridden by the second argument

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to serialize to a JSON string
encodingan optional output encoding for the resulting JSON string; if this argument is not passed, then UTF-8 encoding is used by default
Returns
the JSON string corresponding to the arguments passed, formatted with line breaks for easier readability
Exceptions
JSON-SERIALIZATION-ERRORcannot serialize value passed (ex: binary, object)
Example:
my string $json = makeFormattedJSONString($data);
See Also
Automatic JSON Serialization and Deserialization
string Qore::Json::makeJSONString ( any  data,
*string  encoding 
)

Serializes qore data into a JSON string, without any line breaks.

By default the string produced will be in UTF-8 encoding, but this can be overridden by the second argument

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to serialize to a JSON string
encodingan optional output encoding for the resulting JSON string; if this argument is not passed, then UTF-8 encoding is used by default
Returns
the JSON string corresponding to the arguments passed, without any line breaks
Exceptions
JSON-SERIALIZATION-ERRORcannot serialize value passed (ex: binary, object)
Example:
my string $json = makeJSONString($data);
See Also
Automatic JSON Serialization and Deserialization
nothing Qore::Json::parseJSON ( )

This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters.

Code Flags:
RUNTIME_NOOP
any Qore::Json::parseJSON ( string  json_str)

Parses a JSON string and returns the corresponding Qore data structure.

Code Flags:
RET_VALUE_ONLY
Parameters
json_strthe JSON string to parse
Returns
the Qore data structure corresponding to the input string
Exceptions
JSON-PARSE-ERRORsyntax error parsing JSON string
Example:
my any $data = parseJSONValue($json);
See Also
Automatic JSON Serialization and Deserialization