FHIR Chat · Duplicate Properties in JSON · conformance

Stream: conformance

Topic: Duplicate Properties in JSON


view this post on Zulip Grahame Grieve (Aug 18 2019 at 06:01):

This:

 {“resourceType”:“Patient”, “active”:false, “active”:true}

In this case, should the validator make this an error or a warning?

view this post on Zulip Grahame Grieve (Aug 18 2019 at 06:03):

if you think it's an error, on what do you base your argument? (quote from a standard please)

view this post on Zulip David Hay (Aug 19 2019 at 03:03):

I'm confused - active is 0..1

view this post on Zulip Grahame Grieve (Aug 19 2019 at 03:35):

There’s only one active property...

view this post on Zulip Oliver Egger (Aug 19 2019 at 06:14):

I think it should be an error, http://www.hl7.org/fhir/json.html says: Property names SHALL be unique. Note: this is not explicitly stated in the original JSON specification,so stated for clarity here

view this post on Zulip Grahame Grieve (Aug 19 2019 at 09:46):

oh I missed that

view this post on Zulip Grahame Grieve (Aug 19 2019 at 09:58):

hmm, the validator already gives this error:

view this post on Zulip Grahame Grieve (Aug 19 2019 at 09:58):

FATAL: (document): Error parsing JSON: Error parsing JSON source: Duplicated property name: active at Line 10 (path=[/true])

view this post on Zulip Grahame Grieve (Aug 19 2019 at 09:59):

I added a test case to make sure.

view this post on Zulip Mukesh Sharma (Aug 19 2019 at 15:42):

hmm, the validator already gives this error:

But why does the HAPI library 3.7.0 FhirValidator not give this error?

view this post on Zulip Grahame Grieve (Aug 19 2019 at 18:37):

I don

view this post on Zulip Grahame Grieve (Aug 19 2019 at 18:37):

I don't know. it's the same code, so it should. DOes the HAPI 4.0.0 one give the error?

view this post on Zulip Lloyd McKenzie (Aug 20 2019 at 16:42):

@James Agnew

view this post on Zulip Alexander Kiel (Aug 20 2019 at 17:50):

Which JSON parser returns duplicate keys and how? Or is the validation done before parsing? Parsers in Clojure, I use, return maps for JSON objects. Maps can't have duplicate keys.

view this post on Zulip Bryn Rhodes (Aug 20 2019 at 18:47):

They typically don't return the duplicates, but some parsers will just ignore them, as opposed to raising an error during parsing.

view this post on Zulip Grahame Grieve (Aug 20 2019 at 21:00):

the validator uses a custom json parser in order to get line / col number, and the custom parser picks it up. So that's useful - if you pass the bytes to the validator, it can pick up this problem. But if you use any other parser, and then pass the resulting object to the validator, it won't report this problem because the source parser (any other json parser) will hide the problem somehow

view this post on Zulip Alexander Kiel (Aug 21 2019 at 07:57):

Yes my parser just returns one of the key-value pairs.


Last updated: Apr 12 2022 at 19:14 UTC