JSON (JavaScript Object Notation) functions allow serializing and deserializing between JSON strings and qore data structures. There are also functions for JSONRPC support for easier integration with JavaScript clients; see below for details.
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.
makeJSONString(Any Type, [Encoding]
)
$json = makeJSONString($value);
Table 3.445. Arguments and Return Values for makeJSONString()
Argument Type |
Return Type |
Description |
---|---|---|
Any Type, [Encoding] |
String |
Serializes qore data into a JSON string, without any line breaks. |
Table 3.446. Exceptions Thrown by makeJSONString()
err | desc |
---|---|
| Error serializing to JSON string. |
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.
makeFormattedJSONString(Any Type, [Encoding]
)
$json = makeFormattedJSONString($value);
Table 3.447. Arguments and Return Values for makeFormattedJSONString()
Argument Type |
Return Type |
Description |
---|---|---|
Any Type, [Encoding] |
String |
Serializes qore data into a JSON string, formatted with line breaks for easier readability. |
Table 3.448. Exceptions Thrown by makeFormattedJSONString()
err | desc |
---|---|
| Error serializing to JSON string. |
Creates a JSON-RPC request string from the parameters passed, without any line breaks. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeJSONRPCRequestString(method_name, [json_version], [id], [arguments]
)
$json = makeJSONRPCRequestString("method_name", "1.1", $id, $request_data);
Table 3.449. Arguments and Return Values for makeJSONRPCRequestString()
Argument Type |
Return Type |
Description |
---|---|---|
Method_name, [json_version], [id], [arguments] |
String |
Creates a JSON-RPC request string from the parameters passed, without any line breaks. |
Table 3.450. Exceptions Thrown by makeJSONRPCRequestString()
err | desc |
---|---|
| Error serializing to JSON string. |
| missing method name as first parameter. |
Creates a JSON-RPC request string from the parameters passed, formatted with line breaks for easier readability. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeFormattedJSONRPCRequestString(method_name, [json_version], [id], [arguments]
)
$json = makeFormattedJSONRPCRequestString("method_name", "1.1", $id, $request_data);
Table 3.451. Arguments and Return Values for makeFormattedJSONRPCRequestString()
Argument Type |
Return Type |
Description |
---|---|---|
Method_name, [json_version], [id], [arguments] |
String |
Creates a JSON-RPC request string from the parameters passed, formatted with line breaks for easier readability. |
Table 3.452. Exceptions Thrown by makeFormattedJSONRPCRequestString()
err | desc |
---|---|
| Error serializing to JSON string. |
| missing method name as first parameter. |
Creates a JSON-RPC response string from the parameters passed, without any line breaks. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeJSONRPCResponseString([json_version], [id], [response]
)
$json = makeJSONRPCResponseString("1.1", $id, $response);
Table 3.453. Arguments and Return Values for makeJSONRPCResponseString()
Argument Type |
Return Type |
Description |
---|---|---|
[json_version], [id], [response] |
String |
Creates a JSON-RPC response string from the parameters passed, without any line breaks. |
Table 3.454. Exceptions Thrown by makeJSONRPCResponseString()
err | desc |
---|---|
| Error serializing to JSON string. |
Creates a JSON-RPC response string from the parameters passed, formatted with line breaks for easier readability. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeFormattedJSONRPCResponseString([json_version], [id], [response]
)
$json = makeFormattedJSONRPCResponseString("1.1", $id, $response);
Table 3.455. Arguments and Return Values for makeFormattedJSONRPCResponseString()
Argument Type |
Return Type |
Description |
---|---|---|
[json_version], [id], [response] |
String |
Creates a JSON-RPC response string from the parameters passed, formatted with line breaks for easier readability. |
Table 3.456. Exceptions Thrown by makeFormattedJSONRPCResponseString()
err | desc |
---|---|
| Error serializing to JSON string. |
Creates a generic JSON-RPC error response string from the parameters passed, without any line breaks. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeJSONRPCErrorString([json_version], [id], [response]
)
$json = makeJSONRPCErrorString("1.1", $id, $response);
Table 3.457. Arguments and Return Values for makeJSONRPCErrorString()
Argument Type |
Return Type |
Description |
---|---|---|
[json_version], [id], [response] |
String |
Creates a generic JSON-RPC error response string from the parameters passed, without any line breaks. |
Table 3.458. Exceptions Thrown by makeJSONRPCErrorString()
err | desc |
---|---|
| Error serializing to JSON string. |
Creates a generic JSON-RPC error response string from the parameters passed, formatted with line breaks for easier readability. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeFormattedJSONRPCErrorString([json_version], [id], [response]
)
$json = makeFormattedJSONRPCErrorString("1.1", $id, $response);
Table 3.459. Arguments and Return Values for makeFormattedJSONRPCErrorString()
Argument Type |
Return Type |
Description |
---|---|---|
[json_version], [id], [response] |
String |
Creates a generic JSON-RPC error response string from the parameters passed, formatted with line breaks for easier readability. |
Table 3.460. Exceptions Thrown by makeFormattedJSONRPCErrorString()
err | desc |
---|---|
| Error serializing to JSON string. |
Creates a JSON-RPC 1.1 error response string from the parameters passed, without any line breaks. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The last argument can be of any qore type (or complex data structure).
makeJSONRPC11ErrorString(code, message, [[id], [error]
)
$json = makeJSONRPC11ErrorString(200, $msg, $id, $error);
Table 3.461. Arguments and Return Values for makeJSONRPC11ErrorString()
Argument Type |
Return Type |
Description |
---|---|---|
Code, Error_message, [id], [error_response] |
String |
Creates a JSON-RPC 1.1 error response string from the parameters passed, formatted with line breaks for easier readability. |
Table 3.462. Exceptions Thrown by makeJSONRPC11ErrorString()
err | desc |
---|---|
| Error serializing to JSON string. |
| Invalid argument to method. |
Creates a JSON-RPC 1.1 error response string from the parameters passed, formatted with line breaks for easier readability. To follow JSON-RPC specifications, the generated string will always be in UTF-8 encoding. The first code argument must be an integer between 100 and 999 (inclusive). The last argument can be of any Qore type (or complex data structure).
makeFormattedJSONRPC11ErrorString(code, error_message, [id], [error_response]
)
$json = makeFormattedJSONRPC11ErrorString(200, $msg, $id, $error);
Table 3.463. Arguments and Return Values for makeFormattedJSONRPC11ErrorString()
Argument Type |
Return Type |
Description |
---|---|---|
Code, Error_message, [id], [error_response] |
String |
Creates a JSON-RPC 1.1 error response string from the parameters passed, formatted with line breaks for easier readability. |
Table 3.464. Exceptions Thrown by makeFormattedJSONRPC11ErrorString()
err | desc |
---|---|
| Error serializing to JSON string. |
| Invalid argument to method. |
Parses a JSON string and returns the corresponding qore data structure.
parseJSON(json_string
)
$data = parseJSON($json_string);
Table 3.465. Arguments and Return Values for parseJSON()
Argument Type |
Return Type |
Description |
---|---|---|
Json_string |
Qore Data |
Parses a JSON string and returns the corresponding qore data structure. |