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.
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(softint $code, string $error, any $id, any $error_response) returns string
$json = makeFormattedJSONRPC11ErrorString(200, $msg, $id, $error);
Table 3.483. Exceptions Thrown by makeFormattedJSONRPC11ErrorString()
err | desc |
|---|---|
| Error serializing to JSON string. |
| Invalid argument to method. |
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(any $json_version, any $id, any $response_msg) returns string
$json = makeFormattedJSONRPCErrorString("1.1", $id, $response);
Table 3.485. Exceptions Thrown by makeFormattedJSONRPCErrorString()
err | desc |
|---|---|
| Error serializing to JSON string. |
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(string $method_name, any $json_version, any $id, any $request_msg) returns string
$json = makeFormattedJSONRPCRequestString("method_name", "1.1", $id, $request_data);
Table 3.487. 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, 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(any $json_version, any $id, any $response_msg) returns string
$json = makeFormattedJSONRPCResponseString("1.1", $id, $response);
Table 3.489. Exceptions Thrown by makeFormattedJSONRPCResponseString()
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 $data, string $encoding) returns string
makeFormattedJSONString(any $data) returns string
$json = makeFormattedJSONString($value);
Table 3.491. Exceptions Thrown by makeFormattedJSONString()
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(softint $code, string $error, any $id, any $error_response) returns string
$json = makeJSONRPC11ErrorString(200, $msg, $id, $error);
Table 3.493. Exceptions Thrown by makeJSONRPC11ErrorString()
err | desc |
|---|---|
| Error serializing to JSON string. |
| Invalid argument to method. |
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(any $json_version, any $id, any $response_msg) returns string
$json = makeJSONRPCErrorString("1.1", $id, $response);
Table 3.495. Exceptions Thrown by makeJSONRPCErrorString()
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(string $method_name, any $json_version, any $id, any $request_msg) returns string
$json = makeJSONRPCRequestString("method_name", "1.1", $id, $request_data);
Table 3.497. Exceptions Thrown by makeJSONRPCRequestString()
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(any $json_version, any $id, any $response_msg) returns string
$json = makeJSONRPCResponseString("1.1", $id, $response);
Table 3.499. Exceptions Thrown by makeJSONRPCResponseString()
err | desc |
|---|---|
| Error serializing to JSON string. |
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 $data, string $encoding) returns string
makeJSONString(any $data) returns string
$json = makeJSONString($value);
Table 3.501. Exceptions Thrown by makeJSONString()
err | desc |
|---|---|
| Error serializing to JSON string. |