Dean,
thanks for the clarification. I was trying to apply the idea of
associative arrays to the standard link definition in the draft JSON
schema RFC, in order to improve direct access to a link, by name (see
http://ekrantz.com/index.php/2007/06/06/json-and-associative-arrays.html).
While applying that idea, I used [] where these examples used {},
probably by blindly following my expectation that an associative
*array* would use []. Sorry for that.
All,
Direct access by name is an important criteria for what we are doing,
and the standard link definition in the draft JSON schema RFC misses
that point, unfortunately. We also need this for other cases of direct
access, I was just using the link case as an example.
Let me know if you think that direct access to a specific link by its
link name is something that can be done efficiently and with minimal
coding (i.e. without a loop) from languages like Python or Javascript
by using properties of array items, as in the standard link definition
when using the "rel" property as the link name. My assumption was that
this is not possible, and that the associative array approach
described in the referenced article is what enables that.
So here is my next attempt, with some more questions:
Schema:
{
"name": "LinksSchema",
"description": "A set of links.",
"type": "object",
"properties": {
"<link-name>": {
"description": "A link. <link-name> is the name of the link.
There is one <link-name> property for each link in the set.",
"type": "object",
"properties": {
"href": {
"description": "A URI that is the target of the link.",
"type": "string"
}
}
}
}
}
Example property whose value is described by that schema:
"links": {
"self": {
"href": "some-uri"
},
"parent": {
"href": "some-other-uri"
}
}
Again, I am aware that the standard link definition is different, and
I have other use cases that lead to the same questions.
My questions are:
- Is there a better way to describe the name of the link (which is
unknown at the time the schema is defined) than by inventing a
template syntax such as "<link-name>" ?
- I'd like to use this schema in multiple other schemas without
repeating it. Is there a way a schema defining an object can be named
and referenced for defining an object type in another schemas ? More
or less like a type name in W3C XML Schema?
- I found the draft RFC uses a "name" property in its first example
(the first occurence of "name" directly after the top-level left
brace) that sounds like a schema name, but the draft RFC does not
explain that property anywhere. The schema shown above used that as
well. The schema and hyper-schema examples on
json-schema.org use "id"
and "$schema" properties that seem to have an identifying role, but
again these properties are not described in the draft RFC. Does anyone
know the intention of the IETF group owning the draft RFC, for these
three properties (name, id, $schema) or for the general problem of
identifying and referencing a schema ?
Andy