Sha256: 27dc868b17928eac9089ac0d626ab4912c1819b7b2c3aa601ec34ab1bdc01e1a
Contents?: true
Size: 691 Bytes
Versions: 6
Compression:
Stored size: 691 Bytes
Contents
module ChartMogul module Utils class JSONParser class << self def parse(json_string) hash = JSON.parse(json_string, symbolize_names: true) HashSnakeCaser.new(hash).to_snake_keys end def typecast_custom_attributes(custom_attributes) return {} unless custom_attributes custom_attributes.each_with_object({}) do |(key, value), hash| hash[key] = opt_string_to_time(value) end end def opt_string_to_time(value) return value unless value.instance_of?(String) Time.iso8601(value) rescue Time.rfc2822(value) rescue value end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems