Describe LAST item of array in json schema?

Viewed 98

I use JSON Schema to describe my data structure

My data contains specific arrays of the following structure:

{
    "string1",
    "string2",
    ...
    "stringN",
    {
       "object": "as",
       "last": "item"
    }
}

I'm wondering how to describe this in json schema (especially the thing "last item is an object")

If I knew the number of string items, "prefixItems" would do the thing (but there could be any number of them).

If the object was the first (not last) item, "prefixItems" together with "items" would work.

If is use "contains", it only checks the object is somewhere in my array, not checking it is the last item.

Seems that I need something like "reversePrefixItems", if such option existed - but it doesn't exists.

So, what is a proper way to describe the last item of an array? (and optionally all the preceding ones - knowing their type but not their total count)

1 Answers

there has been discussion of a proposed keyword postfixItems but it has not yet made it into the spec. I don't think there is a way to do this currently.

Related