module Sensu::JSON
Public Class Methods
dump(object, options={})
click to toggle source
Dump (generate) a JSON
string from a Ruby object.
@param object [Object] @param options [Hash]
# File lib/sensu/json.rb, line 42 def dump(object, options={}) @@parser.dump(object, options) end
load(string)
click to toggle source
Load (and parse) a JSON
string.
@param string [String] @return [Object]
# File lib/sensu/json.rb, line 30 def load(string) begin @@parser.load(string) rescue => error raise Sensu::JSON::ParseError.build(error, string) end end
setup!()
click to toggle source
Set up the JSON
parser. This method must be called before any attempt to use the parser. This method is currently called at the bottom of this file. The appropriate JSON
parser will be loaded for the current platform.
@return [Object] parser.
# File lib/sensu/json.rb, line 15 def setup! @@parser = case when RUBY_PLATFORM =~ /java/ require "sensu/json/jrjackson" Sensu::JSON::JrJackson.new else require "sensu/json/oj" Sensu::JSON::Oj.new end end