Need help composing a json-schema definition

117 views
Skip to first unread message

Zhami

unread,
Jun 9, 2011, 10:10:37 AM6/9/11
to nodejs
I've got a JSON object that contains "items" that are objects. The
contained objects are "well-formed" in the sense that they have
consistent property names. However, the containing object does not
because it is used as a hash, so that the property names are distinct
names for the contained objects. I can write a json schema for the
contained objects, but don't know how to specify a schema for the
containing object, which effectively has a wildcard-string as the
property name. Can json schema specify such? If I haven't been clear,
please see an pseudo-example object at this gist: https://gist.github.com/1016737

Joshua Cohen

unread,
Jun 9, 2011, 10:32:50 AM6/9/11
to nod...@googlegroups.com
Try either patternProperties or additionalProperties.


Something like:

{
    "properties" : {
        "prop1" : {
            "type" : "string"
        },
        "prop2" : {
            "type" : "string"
        }
    }
}

{
    "patternProperties" : {
        "*" : { "$ref" : "http://example.com/some/other/schema/uri" }
    }
}


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Reply all
Reply to author
Forward
0 new messages