JSON Schema is a powerful tool used to define and validate the structure of JSON data. Mastering JSON Schema concepts is critical for developers preparing for interviews, as it demonstrates proficiency in designing and validating JSON data structures. The following MCQs are curated to help you understand JSON Schema basics, advanced concepts, and practical usage.
1.) What is JSON Schema?
A) A format to store JSON data
B) A method to minify JSON files
C) A library to parse JSON data
D) A specification to define and validate the structure of JSON data
2.) Which keyword in JSON Schema defines the type of a value?
A) format
B) type
C) properties
D) items
3.) What does the properties keyword do in JSON Schema?
A) Defines the keys allowed in an object
B) Specifies the data type of an array
C) Lists all required fields in an object
D) Defines the maximum number of keys in an object
4.) Which keyword is used to specify required fields in a JSON object?
A) mandatory
B) required
C) fields
D) include
5.) What does the enum keyword specify in JSON Schema?
A) The default value of a property
B) The format of a date field
C) The maximum length of a string
D) A list of allowed values for a property
6.) How do you specify that a JSON object must have at least one key in JSON Schema?
A) minItems: 1
B) minProperties: 1
C) minKeys: 1
D) required: true
7.) Which keyword specifies the schema for items in a JSON array?
A) properties
B) type
C) items
D) definitions
8.) What is the purpose of the additionalProperties keyword?
A) To define extra fields that are allowed in an object
B) To validate nested objects
C) To specify array constraints
D) To allow duplicate keys in an object
9.) What does the oneOf keyword do in JSON Schema?
A) Validates against one specific type
B) Requires all listed schemas to match
C) Combines multiple schemas
D) Ensures that the data matches exactly one of the specified schemas
10.) Which keyword defines a numeric range in JSON Schema?
A) min and max
B) minimum and maximum
C) range
D) numberRange
Related