No, additionalProperties defaults to an empty schema. The algorithm to
lookup the schema associated to an object key is as such:
* if a key exists by its exact name in "properties", then the key must
obey the relevant schema;
* if the key matches one or more keys in "patternProperties", then it
must also obey _all_ schemas defined by these keys;
* if and only if no schema has matched so far, the schema defined by
"additionalProperties" is considered.
If additionalProperties is false and the key has matched no schema so
far, then the JSON instance does not match against the schema.
Hope this helps,
--
Francis Galiegue, fgal...@gmail.com
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)
And how would you go about discerning a regular key from a regex
pattern? Any string is valid as a key name...
Any other ideas?
Greatly appreciate your help
-Sergey
_____________________________________________________
This electronic message and any files transmitted with it contains
information from iDirect, which may be privileged, proprietary
and/or confidential. It is intended solely for the use of the individual
or entity to whom they are addressed. If you are not the original
recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email
in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email
in error, please delete it and immediately notify the sender.
_____________________________________________________
Your second guess is good. But your schema is not: minItems and
maxItems are "first-class" keywords for describing arrays. Similarly,
the default keyword should be at the top level of the schema. Your
schema should read:
{
"type": "array",
"items": {
"type": "integer"
},
"minItems": 4,
"maxItems": 4,
"default": [ 0, 0, 0, 300 ]
}
Hope this helps,
-Sergey
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To post to this group, send email to json-...@googlegroups.com.
To unsubscribe from this group, send email to json-schema...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-schema?hl=en.
This way I can use values defined in third party libraries
Strictly speaking, you can't. JSON Schema is language agnostic (I
implement it in Java for instance, but implementations exist in Ruby,
PHP, C++...).
What you can do, however, is use JavaScript to build the schema and
then feed it to a validator.
Scalar:
{}
And
{
"title": "deafult integer",
"type": "object",
"properties": {
"my1integers":{
"required":true,
"description": "Single integer",
"default":0
}
}
}
Generates
{
"my1integers": 0
}
But
{}
and
{
"title": "deafult array of integers",
"type": "object",
"properties": {
"my4integers":{
"required":true,
"description": "Array of 4 integers",
"type": "array",
"items": {
"title": "Array values",
"type":"integer"
},
"minItems":4,
"maxItems":4,
"default":[0,0,0,300]
}
}
}
Throws error exception
-----Original Message-----
From: json-...@googlegroups.com [mailto:json-...@googlegroups.com] On Behalf Of Francis Galiegue
Sent: Thursday, March 01, 2012 3:13 AM
To: json-...@googlegroups.com
Subject: Re: [json-schema] default value for an array
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To post to this group, send email to json-...@googlegroups.com.
To unsubscribe from this group, send email to json-schema...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-schema?hl=en.
My implementation is a pure validator, it does not alter its inputs in
any way. That is for when I decide on implementing JSON patch ;) Not
today, though...