Stream: implementers
Topic: A JSON format with ordered "keys"
Paul Lynch (Jan 16 2019 at 18:48):
At the connectathon, there was a breakout session in which discussion briefly digressed to an unrelated problem of parsing extremely large FHIR resources from JSON, in which the keys are unordered, which can cause processing of the parsed resource (if using a streaming parser) to be less efficient than it would be if the order of the keys could be specified and fixed. There was no serious suggestion of changing the format, but I got to thinking about it anyway, and it occurred to me if such an opportunity presented itself at some point in the future (which I gather is not likely now that R4 is out), one could constrain the order of the elements by using an array. Instead of having the JSON for a resource look like:
{ key1: value1, key2: value2, key3: value3 }
One could have:
[ {key1: value1}, {key2: value2}, {key3: value3} ]
...in which case the order of the keys would be guaranteed when serialized, and presumably the order could then be required in the resource definition.
nicola (RIO/SS) (Jan 16 2019 at 22:23):
do not think, we should simulate xml :)
but some tricks can be done to improve streaming processing support:
- define ndjson format for search responses etc
- use something like rails root_in_json parameter - https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html
nicola (RIO/SS) (Jan 16 2019 at 22:26):
ndjson support:
GET /Patient?_format=ndjson {resourceType: "Bundle", totla: ...} {rt: Patient ....} {rt: Patient ...} .... ``
nicola (RIO/SS) (Jan 16 2019 at 22:27):
meta outside how RoR do:
{Patient: {resourcebody}} {Encounter: {resourcebody}} {Practitioner: {resourcebody}}
Last updated: Apr 12 2022 at 19:14 UTC