View raw Markdown
type: docsource: source/resource-formats.html

[%settitle Resource Formats%] [%file newheader%] [%file newnavbar%] <%fmtheader formats%>

Resource Formats

Responsible Owner: [[%wgt fhir%]]([%wg fhir%]) Work GroupStandards Status:Normative

Serialization Format Representations

This specification defines the following ways to represent resources when they are exchanged:

Additional Bulk Data Formats are also undergoing exploration. Other representations are allowed, but are not described by this specification.

Systems SHALL declare which format(s) they support in their Capability Statement. If a server receives a request for its Capability Statement in a format it does not otherwise support, it SHALL return a 406 Not Acceptable. Note: 406 is the appropriate response when the Accept header requests a format that the server does not support, and 415 Unsupported Media Type when the client posts a format that is not supported to the server.

Clients and servers can choose what syntax(s) to implement. In the interests of interoperability, servers SHOULD support both the XML and JSON formats, which have the same functionality, for different technical stacks. The RDF (Turtle) format has quite different benefits - primarily around data analysis rather than exchange.

Comparison between JSON and XML

The JSON format is similar to the XML format:

There are differences between XML and JSON:

Implementers should be aware of the difference in this serialization behavior when converting between the syntaxes, including its ramifications on digital signature canonicalizations. The XML format for the resources follows the JSON format closely to make interconversion easy, and so that XPath queries can easily be mapped to query the JSON structures. However, the differences - particularly the repeating element one, which cannot be avoided - mean that generic XML --> JSON converters are not able to perform correctly. The reference platforms provide XML <--> JSON conversion functionality that accommodates these FHIR-specific characteristics.

String handling

String handling is slightly different between XML and JSON

Bulk Data Formats

The XML and JSON formats are designed to support typical system process-based data exchange uses. FHIR is also used to exchange large amounts of data- 1000s of records, or more (up to billions). This specification documents ND-Json (New line delimited JSON) for this usage.

[%file newfooter%]