Module: Hanami::Utils::Json

Defined in:
gems/gems/hanami-utils-1.3.0/lib/hanami/utils/json.rb

Overview

JSON wrapper

If you use MultiJson gem this wrapper will use it. Otherwise - JSON std lib.

Since:

  • 0.8.0

Constant Summary

ParserError =

Since:

  • 0.8.0

::JSON::ParserError
@@engine =

Since:

  • 0.8.0

::JSON

Class Method Summary collapse

Class Method Details

.generate(object) ⇒ String

Generate a JSON document from the given object

Parameters:

  • object (Object)

    any object

Returns:

  • (String)

    the result of the dumping process

Since:

  • 0.9.1

def self.generate(object)
  @@engine.generate(object)
end

.parse(payload) ⇒ Object

Parse the given JSON paylod

Parameters:

  • payload (String)

    a JSON payload

Returns:

  • (Object)

    the result of the loading process

Raises:

Since:

  • 0.9.1

def self.parse(payload)
  @@engine.parse(payload)
end