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
For example, you may represent a street address such as 1600 Pennsylvania Avenue NW as a 4-tuple of the form: ... To do this, we use the prefixItems keyword. prefixItems is an array, where each item is a schema that corresponds to each index of the document's array.
🌐
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
The provided data conforms to the schema by including values for the required properties and ensuring the age is an integer greater than or equal to zero. The address object contains all the necessary properties, and the hobbies property is an array of strings.
🌐
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.
🌐
Opis
opis.io › json-schema › 2.x › array.html
Array type | Opis JSON Schema
First item of the array must be an integer and the second a string. Other items can be anything. Examples · 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, ...
🌐
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" } } } } }
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › type
JSON Schema - Type-specific Keywords
Here is an example of using the string keyword as a single string: ... An array of strings. When type is used as an array, it contains more than one string specifying the types mentioned above.
Find elsewhere
🌐
QA Touch
qatouch.com › home › validating json schema: all you need to know
Validating JSON Schema: All You Need To Know
June 24, 2025 - For illustration, the following ... value is specified using the type keyword. It can accept a single string or an array of strings, each of which is a legitimate JSON type....
🌐
Stack Overflow
stackoverflow.com › questions › 43591947 › array-of-objects-or-strings-in-json-schema
jsonschema - Array of objects or strings in JSON Schema - Stack Overflow
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "My schema", "additionalProperties": false, "properties": { "src": { "type": "array", "additionalItems": false, "items": { "oneOf": [ { "$ref": "#/definitions/svcUrl" }, { "$ref": "#/definitions/svcObj" } ] } } }, "definitions": { "svcUrl": { "type": "string", "pattern": "^file\\:\\/\\/", "required": [] }, "svcObj": { "type": "object", "properties": { "serviceName": { "type": "string" }, "filename": { "type": "string" } }, "required": [ "RequiredProperty", "filename", "serviceName" ] } } }
🌐
Cswr
cswr.github.io › JsonSchema › spec › multiple_types
Multiple Types - JSON Schema
But we could also specify that a certain document may be any number of types, such as string or integer, object or array, etc. The basic declaration of multiple types is through the "type" keyword, where we can now have an array containing different types. For example, the following schema specifies integers and strings:
🌐
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 ...
🌐
Google Groups
groups.google.com › g › json-schema › c › J6QPptNBJgI
json schema for null strings, integers, enums, objects, arrays and empty arrays
I see this as basically a knock-on ... C, where strings are pointers, but they can point to the special value NULL == 0. In JSON, however, properties are allowed to simply not exist. I strongly believe that that the inclusion of · null in the JSON format is mostly to make it more friendly to C/Java/etc. developers. So, what I would personally like to see is for serialisers to produce the schema from Option ...
🌐
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...
🌐
GitHub
github.com › orgs › json-schema-org › discussions › 461
Proposal: supporting array of strings for "description" annotation · json-schema-org · Discussion #461
Currently, only simple strings are permitted for "description" annotations. Given that JSON does not support string continuation, long descriptions can be difficult to read, update, and otherwise m...