module FHIR::STU3::Json
Public Class Methods
from_json(json)
click to toggle source
# File lib/fhir_stu3_models/bootstrap/json.rb, line 14 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
Public Instance Methods
to_json()
click to toggle source
This module includes methods to serialize or deserialize FHIR
resources to and from JSON.
# File lib/fhir_stu3_models/bootstrap/json.rb, line 10 def to_json JSON.pretty_unparse(to_hash) end