module Basquiat::Json

A simple MultiJson wrapper to protect against eventual API changes.

Public Class Methods

decode(object) click to toggle source

De-serializes a JSON into a Hash @see MultiJson.load @param object [Object] object to be de-serialized @return [Hash] Hash representing the JSON. The keys are symbolized by default

# File lib/basquiat/support/json.rb, line 18
def self.decode(object)
  MultiJson.load(object, symbolize_keys: true)
rescue MultiJson::ParseError
  {}
end
encode(object) click to toggle source

Serializes an Object into a JSON @see MultiJson.dump @param object [Object] object to be serialized @return [String] JSON representation of the object

# File lib/basquiat/support/json.rb, line 10
def self.encode(object)
  MultiJson.dump(object)
end