You have defined your schema correctly, except that it doesn't match the data you say you are validating. If you change the property names to match the schema, you still have one issue. If you want to allow "toll" and "message" to be null, you can do the following.
{
"type": "array",
"items": {
"type": "object",
"properties": {
"loc": {
"type": "string"
},
"toll": {
"type": ["string", "null"]
},
"message": {
"type": ["string", "null"]
}
},
"required": [
"loc"
]
}
}
However, that isn't related to the error message you are getting. That message means that data you are validating is not an array. The example data you posted should not result in this error. Are you running the validator on some data other than what is posted in the question?
Answer from Jason Desrosiers on Stack OverflowJSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
In Python, "array" is analogous to the list or tuple type, depending on usage. However, the json module in the Python standard library will always use Python lists to represent JSON arrays. ... List validation: a sequence of arbitrary length where each item matches the same schema.
Cswr
cswr.github.io › JsonSchema › spec › arrays
Arrays - JSON Schema
In this case, we are asking that the first element must be a string, the second one an integer and the third one a boolean. For example, this array validates against the schema ... Note that the default behaviour of JSON Schema allows us to have fewer items, as long as the corresponding (sub)schemas are satisfied.
Videos
Reading JSON with Schema and Exploding Arrays in PySpark
01:31:05
A Few JSON Schema Tips & Tricks: Getting Started - YouTube
12:18
Why does JSON Schema validate so many things? Add More Constraints!
35:46
An Introduction to JSON Schema: A Practical Look - YouTube
12:49
Part 15 - Rest Assured - JSON Schema Validation - YouTube
11:41
7. Karate Framework || JSON Array Validation. - YouTube
JSON Schema
json-schema.org › learn › miscellaneous-examples
JSON Schema - Miscellaneous Examples
This example introduces the enum validation keyword which is used with an array of values that includes an integer (42), a boolean (true), a string ("hello"), null, and an array ([1, 2, 3]). This demonstrates how enum can be used to specify a set of allowed values of different types. ... { "$id": "https://example.com/enumerated-values.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Enumerated Values", "type": "object", "properties": { "data": { "enum": [42, true, "hello", null, [1, 2, 3]] } }}
Opis
opis.io › json-schema › 2.x › array.html
Array type | Opis JSON Schema
An array is valid against this keyword if items are valid against the corresponding schemas provided by the keyword value. The value of this keyword must be an array of valid json schemas, and each item must be valid against the schema defined at the same position (index).
Json-schema
tour.json-schema.org › content › 01-Getting-Started › 05-Arrays
Arrays: Getting Started | A Tour of JSON Schema
Learn how to define arrays in JSON Schema using the type and items keywords, and convert properties to arrays of strings.
Json-schema
tour.json-schema.org › content › 01-Getting-Started › 06-Array-of-Objects
Array of Objects: Getting Started | A Tour of JSON Schema
Learn how to define an array of objects with properties name and level, and how to set the items keyword in JSON schema.
Rjsf-team
rjsf-team.github.io › json schema › arrays
Arrays | react-jsonschema-form
Arrays of a single field type can be specified as follows: import { RJSFSchema } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; const schema: RJSFSchema = { type: 'array', items: { type: 'string', }, }; render(<Form schema={schema} validator={validator} />, document.getElementById('app'));
MuleSoft
help.mulesoft.com › s › question › 0D52T00004mXUrdSAG › how-do-you-define-an-array-containing-arrays-in-a-json-schema
How do you define an array containing arrays in a JSON ...
March 6, 2017 - Loading · ×Sorry to interrupt · Refresh
Json-schema
tour.json-schema.org › content › 04-Arrays › 01-Specifying-Length-of-an-Array
Specifying Length of an Array: Arrays | A Tour of JSON Schema
Consider the employee JSON Document, now has a new field: an array of phone numbers. 1{ 2 "name": "John Doe", 3 "age": 25, 4 "phones": ["123-456-7890", "987-654-3210"] 5} In JSON Schema, you can specify the minimum and maximum number of items in an array using the minItems and maxItems keywords.
IBM
ibm.com › docs › en › cics-ts › 6.x
Variable arrays of elements in DFHJS2LS
JSON can contain arrays of varying numbers of elements. In general JSON Schemas that contain varying numbers of elements do not map efficiently into a single high-level language data structure. CICS uses container-based mappings or inline mappings to handle varying numbers of elements in JSON data.
JSON Schema
json-schema.org › learn › getting-started-step-by-step
Creating your first schema
Add productID, productName, and the new price key to the array: ... ... "properties": { ... "price": { "description": "The price of the product", "type": "number", "exclusiveMinimum": 0 }, }, "required": [ "productId", "productName", "price" ] With the new required keyword and price key, the overall schema looks like this: ... { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "productId": { "description": "The unique identifier for a product", "type": "integer" }, "productName": { "description": "Name of the product", "type": "string" }, "price": { "description": "The price of the product", "type": "number", "exclusiveMinimum": 0 } }, "required": [ "productId", "productName", "price" ]}
Jsonforms
jsonforms.io › examples › array
Array Example - JSON Forms
The array renderer is used, when an object with type array is used. To get a good overview, have a look at the Schema tab in the demo below.
GitHub
github.com › orgs › json-schema-org › discussions › 145
Contains not working as expected with array of objects · json-schema-org · Discussion #145
Using the following schema: { "$schema": "http://json-schema.org/draft-07/schema", "properties": { "elements": { "type": "array", "items": { "type": "object" }, "contains": { "properties": { "someP...
JSON Schema
json-schema.org › understanding-json-schema › structuring
JSON Schema - Modular JSON Schema combination
{ "type": "object", "properties": { "name": { "type": "string" }, "children": { "type": "array", "items": { "$ref": "#" } } }} ... { "name": "Elizabeth", "children": [ { "name": "Charles", "children": [ { "name": "William", "children": [ { "name": "George" }, { "name": "Charlotte" } ] }, { "name": "Harry" } ] } ]} ... Above, we created a schema that refers to itself, effectively creating a "loop" in the validator, which is both allowed and useful.