Module: Canon::JsonParsing
- Defined in:
- lib/canon/json_parsing.rb
Overview
The only place canon talks to a JSON engine. The yeptris fast path (fused C-API materializer) engages through Yeptris::JSON.load — the strict JSON surface pinned to exact JSON.parse semantics upstream; without the native materializer the stdlib parser serves, unchanged. Errors normalize to JSON::ParserError so canon's rescues hold on both engines.
Class Method Summary collapse
Class Method Details
.parse(json) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/canon/json_parsing.rb', line 16 def parse(json) if Canon::YamlBackend.json_yeptris? begin # The strict JSON surface — spec-pinned to exact JSON.parse # semantics upstream, deliberately separate from the YAML # (Psych-contract) surface, which applies the YAML 1.1 quirk # table to JSON-shaped input. ::Yeptris::JSON.load(json) rescue ::Yeptris::JSON::ParseError, ::Yeptris::ParseError => e raise JSON::ParserError, e. end else JSON.parse(json) end end |