liveBook · Manning

Array

As explained in Data-Oriented Programming: Reduce software complexity

An ordered collection whose elements are accessed by numeric position.

An array is an ordered JSON value whose entries can be described and validated as a group. In a search request, fields is an array of requested book fields. section 7.2

JSON Schema marks the value with type "array" and describes each entry through items. The schema can require strings, restrict values with enum, and require the array field itself. section 7.2

Validating requested fields

A request such as {"title":"habit","fields":["title","weight","number_of_pages"]} validates when fields contains strings. A misspelled title property makes the request invalid when title is required. section 7.2

Listing 7.4 Schema for search request with information about array elements
{
  "type": "object",
  "properties": {
    "title": {"type": "string"},
    "fields": {
      "type": "array",
      "items": {"type": "string"}
    }
  }
}

Inspect the schema that adds string constraints to every array element. section 7.2

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains array types, element schemas, enumerated values, required fields, and validation outcomes.
Examples
Uses a book-search request whose fields array contains title, weight, and number_of_pages.
What you can do after
Apply it via JSON Schema to validate array contents and permitted field names.
How it connects
Connects arrays with JSON, JSON Schema, data schemas, data representation, enumeration, and validation.

Also explained in

Compare how 40 books explain array →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.