Altova XMLSpy 2024 Enterprise Edition

An array is a list of zero or more ordered items; it is delimited by square brackets. Each item in the list is assigned a type. The instance listing below is of an object with three properties. The value of each property is an array (delimiters highlighted in yellow).

 

{

"x": [ 1, 2, "abc" ],

"y": [ 3, 4, "def" ],

"z": [ 5, 6, "ghi" ]

}

 

All three arrays in the listing above have the same definition. Each contains three ordered items in the following order: (i) a number item, a (ii) a number item, (iii) a string item. A schema description of this object is shown in the screenshot below. Since the definition is the same for all three arrays, the definition has been created in a global array named array_01. Each of the three arrays (x, y, and z) references the global array array_01.

JSONArray01

In the screenshot above, array x is selected (indicated by its blue highlight), and its details and constraints are shown in the respective entry helpers (see screenshot above). Notice the constraint on the number of allowed items. The number can be edited in the Constraints entry helper and is displayed in the diagram. The array items can be defined in the definition of the array itself, which in this case is the global definition array_01 (screenshot below).

JSONArray02

Note the following points:

 

The unique constraint specifies that all items in the array must be unique.

The numbering of items starts with 0.

The following phrasing in the diagram, 3 <= items <= 3 and Items: 3..3 (see screenshot above), both indicate the minimum and maximum allowed items. In this case, exactly three items must be present.

 

Adding array items, array item wildcards, and the contains keyword

Array items, array item wildcards, and an array's contains keyword are added via the context menu of a definition or an array item.

 

An array item wildcard enables a broader range of objects to be included in the array.

The contains keyword specifies that the value of the contains keyword must be a valid JSON schema and that at least one of the array's elements must be valid against the referenced schema object. From draft 2019-09 onwards, the keywords minContains and maxContains have been introduced. In the Details entry helper, these are shown as the Min and Max properties of the Contains box (see screenshot below), and they define how many items may match the referenced schema object.

JSONSchemaArrayContains

 

© 2017-2023 Altova GmbH