Sha256: faa72f3b844cb9da4a41820de4b201895a08f49df6a0a586bd62f09862f5b9c1
Contents?: true
Size: 642 Bytes
Versions: 3
Compression:
Stored size: 642 Bytes
Contents
module FHIR module Json # # This module includes methods to serialize or deserialize FHIR resources to and from JSON. # def to_json hash = {} hash = self.to_hash JSON.pretty_unparse(hash) end def self.from_json(json) hash = JSON.parse(json) resource = nil begin resourceType = hash['resourceType'] klass = Module.const_get("FHIR::#{resourceType}") resource = klass.new(hash) rescue Exception => 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.6.3 | lib/bootstrap/json.rb |
fhir_models-1.6.2 | lib/bootstrap/json.rb |
fhir_models-1.6.1 | lib/bootstrap/json.rb |