Reputation: 355
I am building a JSON schema to be used within a JSON editor. Within one array will be a set of objects. Each of these objects will have a property "id" that should be a unique identifier .
{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string",
"title": "Name"
},
"brief": {
"type": "string",
"title": "Brief description"
}
},
"required": ["id", "name"]
}
}
Is it possible to specify in the schema that the ID should either:
Upvotes: 1
Views: 1275
Reputation: 31770
No it's not possible. JSON schema is a simple convention for defining and validating the structure of JSON documents, and the typing of values. Validation of values is limited, and something as complex as an incrementing ID is beyond this remit.
You will have to program for this after deserialization, or via some kind of parser.
Upvotes: 1