Class: JSONRPC::Parser
- Inherits:
-
Object
- Object
- JSONRPC::Parser
- Defined in:
- lib/jsonrpc/parser.rb
Overview
JSON-RPC 2.0 Parser for converting raw JSON into JSONRPC objects
The Parser handles converting raw JSON strings into appropriate JSONRPC objects based on the JSON-RPC 2.0 protocol specification.
Instance Method Summary collapse
-
#parse(json) ⇒ Request, ...
Parse a JSON-RPC 2.0 message.
Instance Method Details
#parse(json) ⇒ Request, ...
Parse a JSON-RPC 2.0 message
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jsonrpc/parser.rb', line 37 def parse(json) data = MultiJson.load(json) if data.is_a?(Array) parse_batch(data) else parse_single(data) end rescue MultiJson::ParseError => e raise ParseError.new( data: { details: e., adapter: MultiJson.adapter.name, input_preview: json[0..100] } ) end |