JSON encoding and decoding for FHIR R5 resources and data types.
Each FHIR struct module exposes to_map/1 (for encoding) and from_map/1
(for decoding). This module provides the top-level encode/decode API.
Encoding
FhirEx.JSON.encode!(%Patient{id: "p1", ...})
#=> ~s({"resourceType":"Patient","id":"p1",...})Decoding
FhirEx.JSON.decode!(json_string, FhirEx.Resources.Patient)
#=> %Patient{...}
Summary
Functions
Converts an atom field name to FHIR camelCase JSON key string.
Recursively removes nil values from a map (or list of maps).
Decodes a JSON string into the given FHIR resource or data type module.
Encodes any FHIR struct to a JSON string, dropping nil fields.
Encodes a list of FHIR structs or maps, dropping nil fields in each.
Converts a FHIR struct to a JSON-compatible map with string keys.
Delegates to the module's own to_map/1 if defined, otherwise
does a best-effort field-name camelCasing from the struct.
Functions
Converts an atom field name to FHIR camelCase JSON key string.
Recursively removes nil values from a map (or list of maps).
Decodes a JSON string into the given FHIR resource or data type module.
Encodes any FHIR struct to a JSON string, dropping nil fields.
Encodes a list of FHIR structs or maps, dropping nil fields in each.
Converts a FHIR struct to a JSON-compatible map with string keys.
Delegates to the module's own to_map/1 if defined, otherwise
does a best-effort field-name camelCasing from the struct.