Stream: implementers
Topic: order in JSON transaction
John Moehrke (Feb 19 2019 at 16:12):
Given a "transaction" http://build.fhir.org/http.html#transaction -- a success response is to be a Bundle that contains one entry for each entry in the request, in the same order, ... http://build.fhir.org/http.html#transaction-response
When this is done with JSON,
Then is this "in the same order" still expected? I see mention in the JSON pages about element order, and list preserving... http://build.fhir.org/json.html#xml
The order of properties of an object is not significant in the JSON representation, though order within an array SHALL be maintained
list order preserving might not be understood to mean the same as a requirement that the order in a list is significant.
Lloyd McKenzie (Feb 19 2019 at 16:41):
JSON is expected to maintain order of elements in an array - which includes the array of Bundle entries.
John Moehrke (Feb 19 2019 at 18:27):
I see that requirement... but what I don't see is clarity that one is expected to put things into an array with the expectation that the order you are putting them into the array is important. Which is important in my usecase for making sure that a Transaction Bundle order of elements is the SAME as the Transaction Response Bundle order of elements.... If that is expected, then I understand... but that expectation is not clear from the specification today... and we had some people at IHE Connectathon that disagreed with that expectation given that it is not said anywhere.
Grahame Grieve (Feb 19 2019 at 18:28):
For a batch, or a successful transaction, the response the server SHALL return a Bundle with type set to batch-response or transaction-response that contains one entry for each entry in the request, in the same order, with the outcome of processing the entry
Grahame Grieve (Feb 19 2019 at 18:28):
is that not clear?
John Moehrke (Feb 19 2019 at 18:33):
that line is clear... "in the same order"... but people have pointed out that the JSON page seems to indicate that order means nothing in json.
Grahame Grieve (Feb 19 2019 at 18:34):
The order of properties of an object is not significant in the JSON representation, though order within an array SHALL be maintained
Grahame Grieve (Feb 19 2019 at 18:34):
really, I don't know what more we could say about this
John Moehrke (Feb 19 2019 at 18:35):
well... people have said they are putting the response Bundle together in random order because there is no requirement except to preserve the order
John Moehrke (Feb 19 2019 at 18:36):
"order within an array SHALL be maintained" is only clear on "maintained".. not on initial order
Grahame Grieve (Feb 19 2019 at 18:36):
"people" should read the specification bits I just quoted. : order in an array matters, and the response bundle must contain entries in the same order as the request bundle
John Moehrke (Feb 19 2019 at 18:36):
so... you are answering my question with: "Yes, John, you have the right expectation." I am happy with that
John Moehrke (Feb 19 2019 at 18:37):
I am not complaining.. I seem to have the expectation right.. that is all I am trying to confirm
Grahame Grieve (Feb 19 2019 at 18:39):
yes you have the expectation right
Alexander Kiel (Sep 26 2019 at 15:04):
From json.org:
An array is an ordered collection of values.
Last updated: Apr 12 2022 at 19:14 UTC