I just released a new version of jsonschema 0.2 alpha over at http://code.google.com/p/jsonschema
The source can be downloaded here: jsonschema-0.2a.tar.gz
The documentation can be found here: jsonschema (version 0.2a) documentation
The new release includes the following notable changes.
- The additionalProperties attribute is now validated.
- Using schemas in the type attribute now works properly.
- Changed support for unique attribute to the "identity" attribute (Note: this is not a backwards compatible change)
- Fixed a bug where the original schema object/dictionary was modified by the validator
- Added a new "interactive mode" which will add default values to objects if not specified as readonly by the schema
- Made error messages a bit more friendly.
- Fixed bugs with validating Unicode strings
The additionalProperties attribute is used to define the format of additional properties that aren't explicitly specified in the properties attribute. This is useful for json like
{ | |
bob: 10, | |
sue: 20, | |
bill: 30 | |
} |
where you have some things like game scores and the name of the attribute is someone's name which can't be defined in schema. You can use it like so:
{ | |
"type": "object", | |
"additionalProperties": "integer" | |
} |
The type field was also fixed so that it handles adding schemas as types, so now you can define,
{ | |
"type": [ | |
{ "type": "array", "minItems": 10 }, | |
{ "type": "string", "pattern": "^0+$" } | |
] | |
} |
This can let you define more complex types for use in schema.