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 › 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.
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
Like with items, if you set unevaluatedItems to false, you can disallow extra items in the array. ... Here, all the values are evaluated. The schema passes validation. ... But here, the schema fails validation because "unevaluatedItems": false specifies that no extra values should exist. ... Note that items doesn't "see inside" any instances of allOf, anyOf, or oneOf in the same subschema. So in this next example, items ignores allOf and thus fails to validate.
🌐
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.
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › object
JSON Schema - object
The required keyword takes an array of zero or more strings. Each of these strings must be unique. ... In Draft 4, required must contain at least one string. In the following example schema defining a user record, we require that each user has a name and e-mail address, but we don't mind if they don't provide their address or telephone number: ... { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" }, "address": { "type": "string" }, "telephone": { "type": "string" } }, "required": ["name", "email"]}
🌐
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.
🌐
Opis
opis.io › json-schema › 2.x › array.html
Array type | Opis JSON Schema
Examples · An array is valid against this keyword if all unchecked items are valid against the schema defined by the keyword value. An item is considered unchecked if items keyword or prefixItems keyword (starting with draft 2020-12) contains an array of schemas and doesn’t have a corresponding position (index). The value of the keyword must be a valid json schema (object, boolean).
🌐
JSON Schema
json-schema.org › learn › json-schema-examples
JSON Schema - JSON Schema examples
{ "$id": "https://example.com/ecommerce.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "product": { "$anchor": "ProductSchema", "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number", "minimum": 0 } } }, "order": { "$anchor": "OrderSchema", "type": "object", "properties": { "orderId": { "type": "string" }, "items": { "type": "array", "items": { "$ref": "#ProductSchema" } } } } }}
Find elsewhere
🌐
Gsu
tinman.cs.gsu.edu › ~raj › 8711 › sp21 › json › JSONSchema.html
JSON and JSON Schema
Here is a JSON schema that describes the second representation of a person: e1.schema · { "$schema": "http://json-schema.org/schema#", "$id": "http://yourdomain.com/schemas/myschema.json", "type": "object", "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" }, "birthday": { "type": "string", "format": "date-time" }, "address": { "type": "object", "properties": { "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "country": { "type" : "string" } } } } }
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › json-schema
JSON Schema - GeeksforGeeks
July 15, 2025 - JSON Schema is a content specification language used for validating the structure of a JSON data.It helps you specify the objects and what values are valid inside the object's properties. JSON schema is useful in offering clear, human-readable, and machine-readable documentation. Structure of a JSON Schema: Since JSON format contains an object, array, and name-value pair elements.
🌐
JSON Schema
json-schema.org › understanding-json-schema › structuring
JSON Schema - Modular JSON Schema combination
The $ref keyword may be used to create recursive schemas that refer to themselves. For example, you might have a person schema that has an array of children, each of which are also person instances. schema · { "type": "object", "properties": { "name": { "type": "string" }, "children": { "type": ...
🌐
Json-schema
tour.json-schema.org › content › 01-Getting-Started › 05-Arrays
Arrays: Getting Started | A Tour of JSON Schema
Example: 1{ 2 "skills": { 3 "type": "array", 4 "items": { 5 "type": "string" 6 } 7 } 8} Now, try to modify the hobbies property on the side editor and convert it to an array of strings.
🌐
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.
🌐
Ajv
ajv.js.org › json-schema.html
JSON Schema | Ajv JSON schema validator
The value of the keyword should be an array of unique strings. The data object to be valid should contain all properties with names equal to the elements in the keyword value. ... The value of the keyword should be a map with keys equal to data ...
🌐
Rjsf-team
rjsf-team.github.io › json schema › arrays
Arrays | react-jsonschema-form
import { RJSFSchema } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; const schema: RJSFSchema = { type: 'array', items: { type: 'string', }, additionalItems: { type: 'boolean', }, }; render(<Form schema={schema} validator={validator} />, document.getElementById('app')); Any ...
🌐
OpenAI Developer Community
community.openai.com › api
Tool calling with arrays - building the JSON schema - API - OpenAI Developer Community
June 26, 2024 - Hello. I was looking at this response: '$.function_call' is invalid. Please help - #7 by landonbconnell that actually responded my previous question on how to embed list in tool calling. But I cannot figure out how the original function should be written. I see too many parameters. getNamesAndDescriptions gets “playlists” as List parameter, but how I should specify the other inner parameters (“id”, “playlist_name”, “playlist_description”)? I imagined somthing like: def getNamesAndDescriptio...