module FHIR::DSTU2::Json
Public Class Methods
from_json(json)
click to toggle source
# File lib/fhir_dstu2_models/bootstrap/json.rb, line 14 def self.from_json(json) hash = JSON.parse(json) resource = nil begin resource_type = hash['resourceType'] klass = Module.const_get("FHIR::DSTU2::#{resource_type}") resource = klass.new(hash) rescue => e FHIR::DSTU2.logger.error("Failed to deserialize JSON:\n#{e.message}\n#{e.backtrace}") FHIR::DSTU2.logger.debug("JSON:\n#{json}") resource = nil end resource end
Public Instance Methods
to_json()
click to toggle source
This module includes methods to serialize or deserialize FHIR::DSTU2
resources to and from JSON.
# File lib/fhir_dstu2_models/bootstrap/json.rb, line 10 def to_json JSON.pretty_unparse(to_hash) end