Skip to content

json_rpc_2: Add strictProtocolChecks parameter to Client #2422

Closed

Description

@alexeyinkin

Server and Peer classes have the strictProtocolChecks parameter that allows to skip the check for "jsonrpc":"2.0" field in requests:

if (strictProtocolChecks && !request.containsKey('jsonrpc')) {
throw RpcException(
error_code.INVALID_REQUEST,
'Request must '
'contain a "jsonrpc" key.');
}
if ((strictProtocolChecks || request.containsKey('jsonrpc')) &&
request['jsonrpc'] != '2.0') {
throw RpcException(
error_code.INVALID_REQUEST,
'Invalid JSON-RPC '
'version ${jsonEncode(request['jsonrpc'])}, expected "2.0".');
}

But for Client there's no way to skip that check in a response:

bool _isResponseValid(Object? response) {
if (response is! Map) return false;
if (response['jsonrpc'] != '2.0') return false;

For context, I'm trying to get it working with mjson C library which doesn't add this field in its responses.

Activity

  1. added a commit that references this issue on Oct 10, 2026
    2337f99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions