Problem statement
jsonrpc-core currently provides first-class request-side protocol processing, but response-side protocol handling is not exposed as a dedicated core API.
To improve JSON-RPC 2.0 protocol completeness and consistency, the core should also provide standardized response envelope classification, parsing, and validation aligned with the specification.
Proposed solution
Add response-side protocol components to jsonrpc-core:
JsonRpcEnvelopeClassifier + JsonRpcEnvelopeType (REQUEST, RESPONSE, INVALID)
- Classify single and batch payloads into request/response/invalid at protocol level.
JsonRpcResponseParser
- Parse incoming JSON-RPC response payloads into a canonical incoming-response model.
- Preserve member-presence semantics (
id present, result present, error present).
JsonRpcResponseValidator
- Enforce JSON-RPC 2.0 response constraints:
- Top-level response must be an object.
jsonrpc MUST be "2.0".
id member MUST exist and MUST be string | number | null.
- Exactly one of
result or error MUST be present.
- If
error exists:
error MUST be an object.
error.code MUST be an integer.
error.message MUST be a string.
error.data remains optional.
JsonRpcResponseValidationOptions (fine-grained controls)
- Provide per-rule switches (Jackson-style configuration).
- Default values must follow RFC MUST constraints.
- RFC SHOULD / stricter operational rules (for example, rejecting fractional numeric IDs) are opt-in only.
- Tests and docs
- Add unit tests covering success/failure/exception/branch scenarios for classifier/parser/validator.
- Update
docs/protocol-and-compliance.md and docs/pure-java-guide.md with response-side handling and option usage.
Alternatives considered
- Keep current request-only scope:
- Leaves response-side protocol handling unspecified in core.
- Add classifier only:
- Insufficient for full response protocol correctness.
JSON-RPC behavior impact
No breaking change to existing request dispatch behavior.
This is an additive enhancement in jsonrpc-core to improve protocol completeness and RFC/spec alignment.
Additional context
Scope is strictly protocol-level and transport-agnostic.
No domain-specific policies (session registry, command/event mapping, tenant/edge rules, business status conversion) are included.
Problem statement
jsonrpc-corecurrently provides first-class request-side protocol processing, but response-side protocol handling is not exposed as a dedicated core API.To improve JSON-RPC 2.0 protocol completeness and consistency, the core should also provide standardized response envelope classification, parsing, and validation aligned with the specification.
Proposed solution
Add response-side protocol components to
jsonrpc-core:JsonRpcEnvelopeClassifier+JsonRpcEnvelopeType(REQUEST,RESPONSE,INVALID)JsonRpcResponseParseridpresent,resultpresent,errorpresent).JsonRpcResponseValidatorjsonrpcMUST be"2.0".idmember MUST exist and MUST bestring | number | null.resultorerrorMUST be present.errorexists:errorMUST be an object.error.codeMUST be an integer.error.messageMUST be a string.error.dataremains optional.JsonRpcResponseValidationOptions(fine-grained controls)docs/protocol-and-compliance.mdanddocs/pure-java-guide.mdwith response-side handling and option usage.Alternatives considered
JSON-RPC behavior impact
No breaking change to existing request dispatch behavior.
This is an additive enhancement in
jsonrpc-coreto improve protocol completeness and RFC/spec alignment.Additional context
Scope is strictly protocol-level and transport-agnostic.
No domain-specific policies (session registry, command/event mapping, tenant/edge rules, business status conversion) are included.