Sha256: 93e3c66fe567bf0c5716d0d0e7f2e17822fa0eb363f49ab712e528fadc5e7c55
Contents?: true
Size: 628 Bytes
Versions: 7
Compression:
Stored size: 628 Bytes
Contents
module FHIR module Json # # This module includes methods to serialize or deserialize FHIR resources to and from JSON. # def to_json JSON.pretty_unparse(to_hash) end def self.from_json(json) hash = JSON.parse(json) resource = nil begin resource_type = hash['resourceType'] klass = Module.const_get("FHIR::#{resource_type}") resource = klass.new(hash) rescue => e FHIR.logger.error("Failed to deserialize JSON:\n#{e.backtrace}") FHIR.logger.debug("JSON:\n#{json}") resource = nil end resource end end end
Version data entries
7 entries across 7 versions & 1 rubygems