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 Overflow
🌐
JSON 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.
🌐
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'));
Find elsewhere
🌐
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.
🌐
Ajv
ajv.js.org › json-schema.html
JSON Schema | Ajv JSON schema validator
The array is valid if it contains at least minContains items and no more than maxContains items that are valid against the schema in contains keyword. ... The value of this keyword is a JSON Schema (can be a boolean).
🌐
Red Gate Software
red-gate.com › home › producing data and schemas in json array-of-array format.
Producing Data and Schemas in JSON array-of-array format. - Simple Talk
January 21, 2019 - JSON was initially designed for the informal transfer of data that has no schema. It has no concept of a table, or of an array of identical arrays. This means that it must tell you each key for each object, even if the original data object was ...
🌐
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...
🌐
QA Touch
qatouch.com › home › validating json schema: all you need to know
Validating JSON Schema: All You Need To Know
June 24, 2025 - Validation fails if a value does not fit the designated type. The following schema, for instance, demands that a value be a string: ... The ‘enum’ keyword specifies a list of potential values for a property. Each value in the JSON array must match a valid value for the property.
🌐
GeeksforGeeks
geeksforgeeks.org › json-schema
JSON Schema | GeeksforGeeks
June 22, 2020 - When a JSON object is defined, JSON schema uses name-value pair "type":"object" When arrays are defined, JSON schema uses the name-value pair "type":"array" Example:
🌐
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.