Open kathryn-ods opened 10 hours ago
Ah. That JSON snippet is a bit of a special case. If you paste this in, you'll see the same error message generated, but about a different thing:
[{
"statementId": "019a93f1-e470-42e9-957b-03559861b2e2",
"declarationSubject": "c359f58d2977",
"statementDate": "2020-03-04",
"recordId": "10478c6cf6de",
"recordType": "person",
"recordDetails": {
"isComponent": false,
"personType": "knownPerson",
"identifiers":
{
"id": "test",
"scheme": "GBR-TAXID"
}
}
}
]
So you get the more helpful message:
identifiers
should be a JSON array. Check that value(s) appear within square brackets, [...]
With your JSON snippet, as always the DRT expects the root JSON document to be an array. But there is no key to which the array is a value, hence the unhelpful message.
So I think that this is probably best handled with a bit of coding logic from @radix0000. (And I do think the example you raise is a common mistake, @kathryn-ods, so worth some special handling.)
@radix0000 can you detect when the it's the root value that isn't an array, and in that case use the message:
The dataset should be a JSON array. Check that the object(s) appear within square brackets, [...]
.. and in all other cases use the error message as-is?
Error occured when testing this - the issue is I am only testing one statement and forgot to put [] around the whole statement. I think the error message could be clearer as I wasn't sure what $ meant at first? Kadie - thoughts?