fhirbolt_serde/json/
mod.rs

1//! Deserialize and serialize FHIR resources to and from JSON.
2//!
3//! # Example
4//! ```
5//! // The `Resource` type is an enum that contains all possible FHIR resources.
6//! // If the resource type is known in advance, you could also use a concrete resource type
7//! // (like e.g. `fhirbolt::model::r4b::resources::Observation`).
8//! use fhirbolt::model::r4b::Resource;
9//! use fhirbolt::serde::{DeserializationConfig, DeserializationMode};
10//!
11//! // The type of `s` is `&str`
12//! let s = "{
13//!     \"resourceType\": \"Observation\",
14//!     \"status\": \"final\",
15//!     \"code\": {
16//!         \"text\": \"some code\"
17//!     },
18//!     \"valueString\": \"some value\"
19//! }";
20//!
21//! let r: Resource = fhirbolt::json::from_str(s, Some(DeserializationConfig {
22//!     mode: DeserializationMode::Lax,
23//! })).unwrap();
24//! println!("{:?}", r);
25//! ```
26//!
27//! See [`DeserializationMode`](crate::DeserializationMode) for different supported deserialization modes.
28
29pub mod de;
30pub mod ser;
31
32pub mod error;
33
34pub use de::{from_json_value, from_reader, from_slice, from_str};
35pub use ser::{
36    to_json_value, to_string, to_string_pretty, to_vec, to_vec_pretty, to_writer, to_writer_pretty,
37};
38
39pub use error::{Error, Result};