Module: Ohai::Mixin::JsonHelper
- Defined in:
- lib/ohai/mixin/json_helper.rb
Instance Method Summary collapse
-
#parse_json(response_body, return_on_parse_error = nil) ⇒ Hash
parse JSON data from a String to a Hash.
Instance Method Details
#parse_json(response_body, return_on_parse_error = nil) ⇒ Hash
parse JSON data from a String to a Hash
27 28 29 30 31 32 33 |
# File 'lib/ohai/mixin/json_helper.rb', line 27 def parse_json(response_body, return_on_parse_error = nil) data = String(response_body) parser = FFI_Yajl::Parser.new parser.parse(data) rescue FFI_Yajl::ParseError return_on_parse_error end |