Sha256: d3036eb92df15ea566645b10f6359842159bd5dc3212a873a76f74a47484bca9
Contents?: true
Size: 726 Bytes
Versions: 3
Compression:
Stored size: 726 Bytes
Contents
require 'json' module FHIR module STU3 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::STU3::#{resource_type}") resource = klass.new(hash) rescue => e FHIR::STU3.logger.error("Failed to deserialize JSON:\n#{e.backtrace}") FHIR::STU3.logger.debug("JSON:\n#{json}") resource = nil end resource end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fhir_stu3_models-3.1.1 | lib/fhir_stu3_models/bootstrap/json.rb |
fhir_stu3_models-3.1.0 | lib/fhir_stu3_models/bootstrap/json.rb |
fhir_stu3_models-3.0.2 | lib/fhir_stu3_models/bootstrap/json.rb |