Flashcards on JSON: Data Interchange and Schema
JSON: Data Interchange and Schema for Students
Tap to flip · Swipe to navigate
JSON Schema
39 cards
Card 1
Question: What does the "additionalProperties" keyword do in JSON Schema, and what are its possible values?
Answer: It controls whether an object can have properties not explicitly defined in the schema. Its value can be true (default), false, or a schema (e.g., {"t
Card 2
Question: How do you specify that certain properties of an object are required in JSON Schema?
Answer: By using the "required" keyword with an array of property names, e.g., "required": ["name","email"].
Card 3
Question: How does "patternProperties" work in JSON Schema?
Answer: It allows you to define schemas for properties whose names match a regular expression, e.g., "^S_": {"type":"string"}.
Card 4
Question: What is "propertyNames" used for in JSON Schema, and what's an example?
Answer: It validates the names of an object's properties using a regular expression, e.g., "propertyNames": {"pattern": "^[A-Za-z0-9]*$"}.
Card 5
Question: How do you limit the number of properties in an object in JSON Schema?
Answer: By using "minProperties" and "maxProperties", e.g., "minProperties": 2, "maxProperties": 3.
Card 6
Question: What are "unevaluatedProperties" and when are they used?
Answer: They are similar to additionalProperties and are used when extending closed schemas (see the provided material for details).
Card 7
Question: How do you define an array in JSON Schema where all items must be of a specific type?
Answer: You use "type":"array" along with "items": {"type": "..."}, e.g., "items": {"type":"string"}.
Card 8
Question: How do you limit the length of an array in JSON Schema?
Answer: By using "minItems" and "maxItems", e.g., "minItems": 2, "maxItems": 3.
Card 9
Question: How do you ensure that array items are unique?
Answer: You use "uniqueItems": true.
Card 10
Question: When do you use tuple (prefixItems) validation for arrays in JSON Schema?
Answer: When an array contains items of different types in a fixed order; you use "prefixItems": [ {...}, {...} ].