Sha256: 57793a8390498bf53af014d410e62b34b7abf68fe1c9b5e8d1c121e720816423
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
module LHC::Formats class JSON include LHC::BasicMethodsConcern def self.request(options) options[:headers] ||= {} options[:headers]['Content-Type'] = 'application/json' options[:headers]['Accept'] = 'application/json' options[:format] = new super(options) end def as_json(input) parse(input, Hash) end def as_open_struct(input) parse(input, OpenStruct) end def to_body(input) input.to_json end def to_s 'json' end def to_sym to_s.to_sym end private def parse(input, object_class) ::JSON.parse(input, object_class: object_class) rescue ::JSON::ParserError => e raise LHC::ParserError.new(e.message, input) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lhc-9.0.0 | lib/lhc/formats/json.rb |