FHIR Chat · Can you use a different encoder other than Hapi? · implementers

Stream: implementers

Topic: Can you use a different encoder other than Hapi?


view this post on Zulip Jake (Oct 18 2018 at 14:14):

I would like to know if there are any special scenarios that the Hapi encoder handles that a just any old encoder wouldn't. For example the Java to JSON encoder, would we just be able to use a library like Jackson or something. I would also like to know if there are any metrics for speed performance between the two, is the Hapi encoder slower, and if so, what makes it so?

view this post on Zulip James Agnew (Oct 18 2018 at 14:28):

Jackson and similar libraries are unable to handle HAPI's structures to produce valid FHIR. There are lots of rules in FHIR's encoding that don't get handled properly without using the right parser.

view this post on Zulip Jake (Oct 18 2018 at 14:41):

Thanks James,

Is it that Jackson and similar libraries don't produce valid FHIR JSON (for example), or that those libraries wouldn't be able to handle parsing the FHIR classes at all and would fail to produce any JSON?

view this post on Zulip James Agnew (Oct 18 2018 at 21:12):

I guess basically it's that the HAPI FHIR structures aren't designed for something like Jackson. You could probably create structures that Jackson would be able to turn into FHIR but they would have subtle differences from the HAPI FHIR ones.

E.g. as one simple example: HAPI FHIR knows that a field annotated with @Extension should put the extension URL in an attribute called url on the extension element. Jackson doesn't know anything about FHIR so it creates invalid extensions. I'm sure someone with enough time could work through all of these issues, but I think it's just easier to use the HAPI FHIR parser personally.

view this post on Zulip Grahame Grieve (Oct 18 2018 at 22:39):

cardinality issues, polymorphism. And the structures for native java json libraries would be incompatible with the structures for native java xml libraries

view this post on Zulip Grahame Grieve (Oct 18 2018 at 22:39):

and you don't get all the useful decorations in the java classes.


Last updated: Apr 12 2022 at 19:14 UTC