Method: Frodo::Entity.from_json

Defined in:
lib/frodo/entity.rb

.from_json(json, options = {}) ⇒ Frodo::Entity

Create Entity from JSON document with provided options.

Parameters:

  • json (Hash|to_s)
  • options (Hash) (defaults to: {})

Returns:



152
153
154
155
156
157
158
159
160
161
# File 'lib/frodo/entity.rb', line 152

def self.from_json(json, options = {})
  return nil if json.nil?
  json = JSON.parse(json.to_s) unless json.is_a?(Hash)
   = (json)
  options.merge!(context: ['@odata.context'])

  entity = with_properties(json, options)
  (entity, )
  entity
end