Class: MultiJSON::Adapters::FastJsonparser Private
- Inherits:
-
MultiJSON::Adapter
- Object
- MultiJSON::Adapter
- MultiJSON::Adapters::FastJsonparser
- Defined in:
- lib/multi_json/adapters/fast_jsonparser.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Use the FastJsonparser library to load, and the fastest other available adapter to dump.
FastJsonparser only implements parsing, so the “dump“ side of the adapter is delegated to whichever adapter MultiJSON would pick if FastJsonparser weren’t installed (oj → yajl → jr_jackson → json_gem → gson). The delegate is resolved lazily at the first “dump“ call, not at file load time, so load order doesn’t lock in the wrong delegate. Require any preferred dump backend before the first “dump“ call (typical applications already have “oj“ loaded by then).
Constant Summary collapse
- ParseError =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Exception raised when JSON parsing fails
::FastJsonparser::ParseError
Constants included from Options
Class Method Summary collapse
-
.dump(object, options = {}) ⇒ String
private
Serialize a Ruby object to JSON via the lazy delegate.
Instance Method Summary collapse
-
#load(string, options = {}) ⇒ Object
private
Parse a JSON string into a Ruby object.
Methods inherited from MultiJSON::Adapter
default_dump_options, default_generate_options, default_load_options, default_parse_options, defaults, load
Methods included from Options
#default_dump_options, #default_generate_options, #default_load_options, #default_parse_options, #dump_options, #dump_options=, #generate_options, #generate_options=, #load_options, #load_options=, #parse_options, #parse_options=
Class Method Details
.dump(object, options = {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serialize a Ruby object to JSON via the lazy delegate
35 36 37 |
# File 'lib/multi_json/adapters/fast_jsonparser.rb', line 35 def dump(object, = {}) dump_delegate.dump(object, ) end |
Instance Method Details
#load(string, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse a JSON string into a Ruby object
FastJsonparser.parse only accepts “symbolize_keys“ and raises on unknown keyword arguments, so the adapter explicitly forwards MultiJSON’s canonical “:symbolize_names“ option as FastJsonparser’s native “symbolize_keys:“ kwarg and silently drops the rest. Pass other options through “MultiJSON.parse_options=“ and they’ll apply to whichever adapter MultiJSON selects when fast_jsonparser isn’t installed.
69 70 71 |
# File 'lib/multi_json/adapters/fast_jsonparser.rb', line 69 def load(string, = {}) ::FastJsonparser.parse(string, symbolize_keys: [:symbolize_names]) end |