Module: Basquiat::Json
- Defined in:
- lib/basquiat/support/json.rb
Overview
A simple MultiJson wrapper to protect against eventual API changes.
Class Method Summary collapse
-
.decode(object) ⇒ Hash
De-serializes a JSON into a Hash.
-
.encode(object) ⇒ String
Serializes an Object into a JSON.
Class Method Details
.decode(object) ⇒ Hash
De-serializes a JSON into a Hash
18 19 20 21 22 |
# File 'lib/basquiat/support/json.rb', line 18 def self.decode(object) MultiJson.load(object, symbolize_keys: true) rescue MultiJson::ParseError {} end |
.encode(object) ⇒ String
Serializes an Object into a JSON
10 11 12 |
# File 'lib/basquiat/support/json.rb', line 10 def self.encode(object) MultiJson.dump(object) end |