Class: Sensu::JSON::Oj

Inherits:
Object
  • Object
show all
Defined in:
lib/sensu/json/oj.rb

Overview

The Sensu JSON parser when running on MRI.

Instance Method Summary collapse

Instance Method Details

#dump(object, options = {}) ⇒ Object

Dump (generate) a JSON string from a Ruby object.

Parameters:

  • object (Object)
  • options (Hash) (defaults to: {})


23
24
25
26
# File 'lib/sensu/json/oj.rb', line 23

def dump(object, options={})
  options.merge!(:indent => 2) if options[:pretty]
  ::Oj.dump(object, options)
end

#load(string) ⇒ Object

Load (and parse) a JSON string. Sensu expects symbolized keys.

Parameters:

  • string (String)

Returns:

  • (Object)


15
16
17
# File 'lib/sensu/json/oj.rb', line 15

def load(string)
  ::Oj.load(string, :symbol_keys => true)
end