Enumerated Values II
Previously, we have used enumerated values only for strings. However, you can also use them for any type, including numbers and null values.
1{ 2 "name":"John Doe", 3 "age": 25, 4 "performanceRating": 4 5}
Let's say you want to restrict the performanceRating to only a few specific values. You can use the enum keyword to define the allowed values.
Example
1{ 2 "enum": [1, 2, 3, 4, 5, null] 3}
Now, modify the performanceRating property on the side editor to accept only the values 1, 2, 3, 4, 5, and null.
Loading...
Output
Please click the button or use
Shift+Enter
to view the output