Friday, 15 January 2010

jsonschema - JSON Schema for collections -



jsonschema - JSON Schema for collections -

i looking how write json schema collection of objects within object.

class="lang-json prettyprint-override">{ "name": "sadiq", "age": 68, "email": [ { "emailid": "sadiq@gmail.com" }, { "emailid": "sadiq@yahoo.com" } ], "phone": [ { "phonenumber": "301-215-8006" }, { "phonenumber": "301-215-8007" } ] }

here 1 possible way write schema:

{ "type": "object", "additionalproperties": false, "properties": { "name": { "type": "string", "required": true }, "age": { "type": "integer", "required": true }, "email": { "type": "array", "items": { "type": "object", "additionalproperties": false, "properties": { "emailid": { "type": "string", "required": true } } } }, "phone": { "type": "array", "items": { "type": "object", "additionalproperties": false, "properties": { "phonenumber": { "type": "string", "required": true } } } } } }

possible improvements be:

add regex pattern validate emailid field extract email , phone top level types , refer them in above schema.

jsonschema raml

No comments:

Post a Comment