Class: OxfordDictionary::Deserialize

Inherits:
Object
  • Object
show all
Defined in:
lib/oxford_dictionary/deserialize.rb

Overview

A small service object that parses a JSON payload into an OpenStruct recursively. The keys of the OpenStruct are in camelCase, not snake_case. This keeps the struct more representative of the JSON in the response.

Instance Method Summary collapse

Instance Method Details

#call(payload) ⇒ OpenStruct

Parses a JSON payload into an OpenStruct Nested objects are also parsed into OpenStructs

Parameters:

  • payload (String)

    a JSON string

Returns:

  • (OpenStruct)

    the JSON parsed into OpenStructs recursively



15
16
17
# File 'lib/oxford_dictionary/deserialize.rb', line 15

def call(payload)
  JSON.parse(payload, object_class: OpenStruct)
end