Forum Discussion

charlesfradley's avatar
charlesfradley
Contributor
8 years ago

how to validate JSON schemas with arrays ?

The JSON structure of my customers' project LTNG uses _items  tags everywhere, and that seems to confuse and defeat the normal JSON schema assertion validation features, eg. the "required" keyword ... I need some help figuring this out.  I cannot find anywhere on the internet which explain how to deal with the  _items  tags ... a link would be helpful ... or somebody to discuss it  with.   I cannot figure out how to embed "required" statements into a schema using nested "_items"

 

 The "required" keyword statements work only at the top level, but when I try to insert into nested branches it is ignored ...

 

I cannot find an example on the internet where somebody has used the _items feature in conjunction with "required" statements .... just wondering if somebody has any insight into that...... The standard schemas in the net generally have the "properties" keyword, but this project JSON does not seem to use that.

 

Sample JSON snippet:

 

{
"uuid": "34h43436j346j",
"firstName": "Jane",
"lastName": "Doe",
"suffix": null,
"middleName": "Eve",
"nickname": "Jan",
"personalTitle": null,
"birthDate": "1996-03-16",
"deathDate": null,
"gender": {
"name": "Female",
"uuid": "243h646j"
},
"createdOn": "2016-12-13T04:53:46Z",
"updatedOn": "2016-12-13T04:53:46Z",
"version": 0,
"connections": {
"_items": [
{
"fromDate": null,
"personUuid": null,
"sequenceId": 2,
"sourceUuid": "4tmtmtme75",
"target": {
"birthDate": "1995-04-24",
"connections": {
"_items": []
},
"contactMechanisms": {
"_items": [
{
"contactMechanism": {
"address1": "321 American Ave",
"address2": "Suite 4",
"city": "Jacksonville",
"directions": "Top of the hill on the left.",

 

 

2 Replies