Arrays
Let's convert the hobbies field to an array of strings.
1{ 2 "name": "John Doe", 3 "age": 25, 4 "hobbies": ["reading", "writing"] 5}
In JSON Schema, defining an array is similar to defining an object. Use the type keyword with the value array to define an array.
You can use the items keyword to define the schema of the array elements. The value of items should be a subschema.
Example:
1{ 2 "skills": { 3 "type": "array", 4 "items": { 5 "type": "string" 6 } 7 } 8}
Now, try to modify the hobbies property on the side editor and convert it to an array of strings.
Loading...
Output
Please click the button or use
Shift+Enter
to view the output