JSONEncoder
Less than 1 minute
JSONEncoder
Methods
request
Creates a JSON-RPC request string.
public request(string $method, array $params, mixed $requestID): voidParameters
| Parameter | Type | Description |
|---|---|---|
$method | string | the name of the method to be invoked |
$params | array | |
$requestID | mixed |
notification
Creates a JSON-RPC 2.0 notification message.
public notification(string $method, array $params): voidParameters
| Parameter | Type | Description |
|---|---|---|
$method | string | the name of the method to invoke |
$params | array | optional parameters to include with the notification |
response
Generates a JSON-RPC 2.0 response string.
public response(mixed $result, mixed $requestID): voidParameters
| Parameter | Type | Description |
|---|---|---|
$result | mixed | the result data to be returned in the response |
$requestID | mixed | the identifier of the request to correlate with the response |
parse
Parses a JSON-RPC 2.0 message and extracts the method and parameters or result/error.
public parse(string $json, ?string $method, mixed $requestID): voidParameters
| Parameter | Type | Description |
|---|---|---|
$json | string | the JSON string to parse |
$method | string | |
$requestID | mixed |
error
Generates a JSON-RPC 2.0 error response.
public error(\Throwable $exception, mixed $requestID): voidParameters
| Parameter | Type | Description |
|---|---|---|
$exception | \Throwable | |
$requestID | mixed |
encodeResponse
Encodes a JSON-RPC 2.0 response array into a Response object.
public encodeResponse(mixed $response): ResponseParameters
| Parameter | Type | Description |
|---|---|---|
$response | mixed | The response data to encode. Must be an array containing a valid JSON-RPC 2.0 response structure. |
Generated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:26 +0000