A homogeneous string map is an index whose keys are strings and whose values share one type or common shape. Unlike a record, it has unknown field names and consistently shaped values: booksByIsbn maps keys to Book values, while authorsById maps keys to Author values. section 3.2 section 12.1
Keep the distinction clear:
- Use a homogeneous string map for indexes, where elements are accessed by string keys and values have a common shape. section 12.1
- Use a heterogeneous string map for records, where field names are known and values may have different types. section 3.2
- Accept a tradeoff: generic maps increase flexibility and genericity while reducing the safety associated with compile-time fields. section 3.6
Catalog indexes
A catalog can contain booksByIsbn and authorsById. Each is a string-keyed map with no predefined item names: every value under booksByIsbn follows bookSchema, and every value under authorsById follows authorSchema. The map structure stays generic while the value schema supplies the expected shape. section 12.1 section 3.2
Listing 12.5 The JSON Schema for an homogeneous map with values as numbers
{
"type": "object",
"additionalProperties": {"type": "number"}
}
Inspect the JSON Schema pattern: declare an object and use additionalProperties to require every unspecified property value to match one schema. section 12.1
