Parsing and serialization

The Firely .NET SDK reads and writes FHIR data in both JSON and XML. Throughout this section the examples use JSON — by far the most common format. XML works the same way through the equivalent classes, and we point out the few places where it differs.

Almost all work with FHIR data goes through the POCO classes (see Introduction to the FHIR Model in .NET): .NET classes such as Patient that mirror the FHIR resources. The SDK turns serialized FHIR into these POCOs and back again:

Note

The SDK 6 deserializers are built to capture all incoming data, even when it does not perfectly fit the POCO — unknown elements and mismatched values are preserved in the element’s overflow (see Dynamic Access to data) rather than discarded. As a result, the POCO approach handles invalid or cross-version data that older SDKs could not.

For low-level, version-independent access to FHIR data as a generic tree, there is the older ElementModel API, kept for backward compatibility.