Module: Riak::JSON

Defined in:
lib/riak/json.rb

Overview

JSON module for internal use inside riak-client

Instance Method Summary collapse

Instance Method Details

#encode(obj) ⇒ String

Generate a JSON string

Parameters:

  • obj (Array, Hash)

    an object to JSON-encode

Returns:



31
32
33
# File 'lib/riak/json.rb', line 31

def encode(obj)
  MultiJson.dump(obj)
end

#parse(str) ⇒ Array, Hash

Parse a JSON string

Parameters:

  • str (String)

    a JSON payload

Returns:

  • (Array, Hash)

    a Ruby object decoded from the JSON payload



24
25
26
# File 'lib/riak/json.rb', line 24

def parse(str)
  MultiJson.load(str, Riak.json_options)
end