Sha256: 6404d58bdc5f49e7ba225384c9bf4bf4ebe587c038308fe83396f4008add0797
Contents?: true
Size: 751 Bytes
Versions: 3
Compression:
Stored size: 751 Bytes
Contents
require 'json' module FHIR module DSTU2 module Json # # This module includes methods to serialize or deserialize FHIR::DSTU2 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::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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems