FHIR Chat · Empty arrays in JSON · conformance

Stream: conformance

Topic: Empty arrays in JSON


view this post on Zulip Morten Ernebjerg (Oct 22 2020 at 07:38):

Hi :wave: I am wondering how to interpret the following statement in the spec about the JSON representation of resources:

Just as in XML, JSON objects and arrays are never empty, and properties never have null values (except for a special case documented below).

I would read this as saying that empty arrays are invalid in FHIR resources. However, the JAR validator (Version 5.1.16) says the following is valid.

{
    "resourceType": "DocumentReference",
    "status": "current",
    "category": [{
        "coding": []
    }],
    "content": [
        { "attachment": { "contentType": "text/plain", "data": "Zm9v" } }
    ]
}

(It does complain about empty objects, though.) Is the statement from the spec only meant to provide best-practice guidance or is it merely not enforced by the validator?

view this post on Zulip Lloyd McKenzie (Oct 22 2020 at 14:46):

@Grahame Grieve

view this post on Zulip Grahame Grieve (Oct 22 2020 at 20:14):

looks like an oversight to me

view this post on Zulip Lloyd McKenzie (Oct 22 2020 at 20:29):

Do you need a Git issue?

view this post on Zulip Grahame Grieve (Oct 22 2020 at 20:47):

no


Last updated: Apr 12 2022 at 19:14 UTC