Module: JSONAPI::Parser::JSONParser
- Defined in:
- lib/easy/jsonapi/parser/json_parser.rb
Overview
A wrapper class for OJ parser
Class Method Summary collapse
-
.dump(ruby_hash) ⇒ Object
Convert ruby hash into JSON.
-
.parse(document, symbol_keys: true) ⇒ Object
Parse JSON string into a ruby hash.
Class Method Details
.dump(ruby_hash) ⇒ Object
Convert ruby hash into JSON
23 24 25 |
# File 'lib/easy/jsonapi/parser/json_parser.rb', line 23 def self.dump(ruby_hash) Oj.dump(ruby_hash, mode: :compat) end |
.parse(document, symbol_keys: true) ⇒ Object
Parse JSON string into a ruby hash
14 15 16 17 18 19 |
# File 'lib/easy/jsonapi/parser/json_parser.rb', line 14 def self.parse(document, symbol_keys: true) Oj.load(document, symbol_keys: symbol_keys) rescue Oj::ParseError => e raise JSONAPI::Exceptions::JSONParseError, e. end |