1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! JSON serialization wrapper functions for FHIR resources.
//!
//! This module provides thin wrappers around `serde_json` functions,
//! allowing FHIR resources to be serialized and deserialized using
//! the existing `FhirSerde` derive macro implementations.
use crateResult;
use ;
/// Deserialize a FHIR resource from a JSON string.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::from_json_str;
/// use helios_fhir::r4::Patient;
///
/// let json = r#"{"resourceType": "Patient", "id": "example"}"#;
/// let patient: Patient = from_json_str(json)?;
/// ```
/// Serialize a FHIR resource to a JSON string.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::to_json_string;
/// use helios_fhir::r4::Patient;
///
/// let patient = Patient::default();
/// let json = to_json_string(&patient)?;
/// ```
/// Serialize a FHIR resource to a pretty-printed JSON string.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::to_json_string_pretty;
/// use helios_fhir::r4::Patient;
///
/// let patient = Patient::default();
/// let json = to_json_string_pretty(&patient)?;
/// ```
/// Deserialize a FHIR resource from a JSON byte slice.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::from_json_slice;
/// use helios_fhir::r4::Patient;
///
/// let json_bytes = br#"{"resourceType": "Patient", "id": "example"}"#;
/// let patient: Patient = from_json_slice(json_bytes)?;
/// ```
/// Serialize a FHIR resource to a JSON byte vector.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::to_json_vec;
/// use helios_fhir::r4::Patient;
///
/// let patient = Patient::default();
/// let json_bytes = to_json_vec(&patient)?;
/// ```
/// Serialize a FHIR resource to a `serde_json::Value`.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::to_json_value;
/// use helios_fhir::r4::Patient;
///
/// let patient = Patient::default();
/// let json_value = to_json_value(&patient)?;
/// ```
/// Deserialize a FHIR resource from a `serde_json::Value`.
///
/// # Examples
///
/// ```ignore
/// use helios_serde::json::from_json_value;
/// use helios_fhir::r4::Patient;
/// use serde_json::json;
///
/// let json_value = json!({"resourceType": "Patient", "id": "example"});
/// let patient: Patient = from_json_value(json_value)?;
/// ```