Sha256: db138ae04aea1f49a742c6a1b80085d871b3a34bcf53769bc4f4fe9863a6d1ad
Contents?: true
Size: 866 Bytes
Versions: 6
Compression:
Stored size: 866 Bytes
Contents
module LHC::Formats class JSON include LHC::BasicMethodsConcern def self.request(options) options[:headers] ||= {} options[:headers]['Content-Type'] = 'application/json; charset=utf-8' options[:headers]['Accept'] = 'application/json; charset=utf-8' 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) if input.is_a?(String) input else input.to_json end 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
6 entries across 6 versions & 1 rubygems