The schema serve to my system to speak the same language with other
systems. In an example:
|"born" : {"type":["integer","string"], /allow for a numeric year, or a
full date/
"format":"date", /format when a string value is used/
"minimum":1900, /min/max for when a numberic value is used
/|| "maximum":2010,
"optional":true
},
this step indicate that I can receive a date object (with all
informations) or an integer (with year).
Introduce the union only to manage a nullable attribute involve to
manage other information (if then else statements) during the validation.
For my system json schema is became too much expensive.
I think that I must search another method to validate.
|
Kris Zyp ha scritto:
I really don't think you should necessarily be doing format validation,
especially if you are concerned about the complexity/expense of the system.
Of course, JSON Schema is a form of documentation to establish correctness,
and documentation exists at various levels of complexity. There is minimal
level correctness that can it is dictated by types, and there is higher
level of correctness (reasonable data) that can only be discerned from
descriptions. "format" falls in between, and in addition is probably the
most likely area of JSON Schema to change/evolve. It is naive to assume that
you can have just one level of bound of correctness, and that will solve all
correctness problems. Documentation like JSON Schema can and should be
progressive in it's ability to describe acceptable data.
> I can't encourage the use of Object because It's can cause
> ClassCastException or useless prolongation of code.
How then would you describe a property that can have an integer or string? I
would assume that without union types, you would have to use "any", which
presumably you would translate to the Java type Object, and you would be
back to where you started, except the Schema would be less descriptive, have
a lower level of validation capability and provide less information for
languages that do support union types.
Kris
For me is OK (although I think that the property nillable is more readable).
Kris Zyp ha scritto:
Kris
>
> What about name collision?
> >
>
>
>
"type" : [
{
"name" : {"type" : "string"...},
"surname" : {...},
...
},
{
"enterpriceName" : {...},
...
}
],
Kris Zyp ha scritto:
Kris Zyp ha scritto:
>
Kris Zyp ha scritto:
----- Original Message -----
From: "Claudio D'Angelo" <claudio...@lombardia-servizi.it>
To: "JSON Schema" <json-...@googlegroups.com>
Sent: Tuesday, January 08, 2008 8:58 AM
Subject: Discussion on json-schema-proposal---first-draft
>
I still think that using "*" would make a more readable equivalent schema:
{"type":{"foo":{"type":"string"},
"*":{"type":"number"}}
}
But it does introduce a name clash, and it is worth noting that a parallel
situation exists in the SMD (service mapping definition) with parameters,
and I would like to keep them in sync (SMD has an additionalParameters
property). Change both, or neither...
Kris
----- Original Message -----
From: "Claudio D'Angelo" <claudio...@lombardia-servizi.it>
To: "JSON Schema" <json-...@googlegroups.com>
Sent: Tuesday, January 08, 2008 1:33 AM
Subject: Discussion on json-schema-proposal---first-draft
>
>
>
Kris Zyp ha scritto:
Kris Zyp ha scritto:
>
>
Referencing and reusing other schemas is certainly one of my primary hopes
and goals for JSON Schema, I think it is central to the ultimate optimal use
of JSON Schema. However, referencing is also not specific to JSON Schema.
Many other forms of JSON stand to benefit from referencing capabilities, and
I don't believe it would be advantageous for JSON Schema to have it's own
referencing convention in contrast to other forms of JSON. One should be
able to use one referencing mechanism and apply it to JSON Schema as well as
other JSON. Therefore, I believe that JSON Schema should lean on another
standard/specification for referencing.
I believe that a standard for JSON referencing would be immensely valuable,
and I have put forth efforts to that end
(http://www.json.com/category/referencing/), albiet without a great deal of
success.
In the spec, I suggested the use of the JSON referencing proposal that I set
forth here:
http://www.json.com/2007/10/19/json-referencing-proposal-and-library/
which was my attempt to put together the best ideas and techniques of the
various referencing techniques that have been used and suggest a compromise
of conventions. With this proposal, one could achieve reuse of schemas by
referencing, and you could create your second schema that references the
first one like:
--schema2.json
{type: [{myProp:{$ref:"schema1.json"}}]}
Although, in this case, it might be more useful to reference the object type
definition than the schema itself.
There are also a number of examples of referencing type definitions in the
common JSON Schema definitions, in the card and calendar schemas:
http://groups.google.com/group/json-schema/web/common-json-schema-definitions
Kris
{type: [{myProp:{$ref:"schema1.json"}}]}
will be parsed how " link another object that has myProp = "schema1.json".
I think that is useful another methodology.
Kris Zyp ha scritto:
Kris Zyp ha scritto:
----- Original Message -----
From: "Claudio D'Angelo" <claudio...@lombardia-servizi.it>
To: "JSON Schema" <json-...@googlegroups.com>
Sent: Friday, January 11, 2008 3:02 PM
Subject: Re: Discussion on json-schema-proposal---first-draft