Class: Hoth::Encoding::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/hoth/encoding/json.rb

Class Method Summary collapse

Class Method Details

.content_typeObject



21
22
23
# File 'lib/hoth/encoding/json.rb', line 21

def content_type
  "application/json"
end

.decode(string) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/hoth/encoding/json.rb', line 12

def decode(string)
  begin
    Hoth::Logger.debug "Original params before decode: #{string.inspect}"
    JSON.parse(string)
  rescue JSON::ParserError => jpe
    raise EncodingError.wrap(jpe)
  end
end

.encode(object) ⇒ Object



8
9
10
# File 'lib/hoth/encoding/json.rb', line 8

def encode(object)
  object.to_json
end