Stream: conformance
Topic: JSON duplicate properties
Michael Lawley (Feb 07 2018 at 23:27):
JSON itself does not forbid duplicate properties, although the spec does observe that they hurt interoperability since various libraries behave differently.
The FHIR spec for application/fhir+json describes how to generate "valid JSON" and the process will not produce duplicate properties.
Are duplicate properties explicitly invalid and thus should a server always report an error when one is encountered?
Lloyd McKenzie (Feb 07 2018 at 23:46):
I would say they're always invalid. If it's a repeating property, all repetitions should appear in the array of a single property. If you'd like to submit a change request for us to make this super explicit, that's not a bad idea.
Michael Lawley (Feb 08 2018 at 02:44):
Done - GF#15290
Grahame Grieve (Feb 08 2018 at 02:51):
yes always invalid.
Michael Lawley (Feb 08 2018 at 05:14):
@James Agnew Looks like HAPI's use of GSON means it silently ignores this - I've filed a bug :)
Lloyd McKenzie (Feb 08 2018 at 05:21):
Technically, servers don't have to reject invalid instances, but agree that this would be a good thing for HAPI to catch.
Jim Steel (Feb 08 2018 at 05:48):
or to be able to catch, at least
Ewout Kramer (Feb 15 2018 at 13:10):
@James Agnew Looks like HAPI's use of GSON means it silently ignores this - I've filed a bug :)
This is exactly what .NET's json parser (Newtonsoft) does - and there's no way to detect it. People have tried to file that as a bug, but the author is pretty stubborn about it. So -at least in .NET- I would not be able to enforce it :-(
Michael Lawley (Feb 17 2018 at 09:19):
I've seen similar threads discussing the issue wrt other JSON parsers too. This doesn't seem like a good situation. I'm wondering how this might interact with digital signatures and Canonical JSON
Grahame Grieve (Feb 17 2018 at 10:13):
it's just a generally bad part of json. Did you see Tim Bray's blog about his revised version of json?
Ewout Kramer (Feb 19 2018 at 15:03):
This? https://www.tbray.org/ongoing/When/201x/2016/08/20/Fixing-JSON
Grahame Grieve (Feb 19 2018 at 19:37):
yes and the rfc he talks about
Last updated: Apr 12 2022 at 19:14 UTC