Sha256: 2df81ed36f355086c99904254f4eaae496f7d9620b3cb437ed3eca1418c59c6f
Contents?: true
Size: 593 Bytes
Versions: 3
Compression:
Stored size: 593 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#{json}\n#{e.backtrace}") resource = nil end resource end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fhir_models-1.8.2 | lib/fhir_models/bootstrap/json.rb |
fhir_models-1.8.1 | lib/fhir_models/bootstrap/json.rb |
fhir_models-1.8.0 | lib/fhir_models/bootstrap/json.rb |