Class: Servicy::Formats::JSON

Inherits:
Servicy::Format show all
Defined in:
lib/formats/json.rb

Class Method Summary collapse

Class Method Details

.format(things) ⇒ Object



7
8
9
# File 'lib/formats/json.rb', line 7

def format(things)
  things.to_json
end

.unformat(things) ⇒ Object



11
12
13
14
# File 'lib/formats/json.rb', line 11

def unformat(things)
  return nil if things == "null"
  return ::JSON.parse(things) rescue ::JSON.parse("[#{things.inspect}]").first
end