View this page "Common JSON Schema Definitions"

28 views
Skip to first unread message

Kris Zyp

unread,
Jan 8, 2008, 4:16:29 PM1/8/08
to JSON Schema
I would like to use these as a beginning repository of commonly
available and reuseable JSON Schema definitions. This will define
instances that are represented with JSON objects. The format attribute
and the formats page will be set of definitions for defining string
(or numbers) values.

Click on http://groups.google.com/group/json-schema/web/common-json-schema-definitions
- or copy & paste it into your browser's address bar if that doesn't
work.

Weston Ruter

unread,
Jan 8, 2008, 5:31:05 PM1/8/08
to JSON Schema
What about "datetime"?

Kris Zyp

unread,
Jan 8, 2008, 5:36:18 PM1/8/08
to json-...@googlegroups.com
The date (with time) is under common formats, so it can be expressed with a
JSON string.
Common formats
(http://groups.google.com/group/json-schema/web/json-schema-possible-formats)
-> definitions for string values
Common schema definitions
(http://groups.google.com/group/json-schema/web/common-json-schema-definitions
) -> definitions for objects
Does that make sense?
Would you like an object form of a date (like
{year:2008,month:1,day:8,hour:15....})?
Kris
----- Original Message -----
From: "Weston Ruter" <Westo...@gmail.com>
To: "JSON Schema" <json-...@googlegroups.com>
Sent: Tuesday, January 08, 2008 3:31 PM
Subject: Discussion on common-json-schema-definitions


>
> What about "datetime"?
> >
>

SMM

unread,
Jan 8, 2008, 6:55:50 PM1/8/08
to JSON Schema
I just finally looked at that list a bit more closely. Seems to me it
would make more sense to use "date-time", "date", and "time", rather
than "date", "date-only", and "time".

On Jan 8, 2:36 pm, "Kris Zyp" <kris...@gmail.com> wrote:
> The date (with time) is under common formats, so it can be expressed with a
> JSON string.
> Common formats
> (http://groups.google.com/group/json-schema/web/json-schema-possible-f...)
>  -> definitions for string values
> Common schema definitions
> (http://groups.google.com/group/json-schema/web/common-json-schema-def...

Kris Zyp

unread,
Jan 8, 2008, 7:11:58 PM1/8/08
to json-...@googlegroups.com
Yes, that would make sense, except... The "date" format as described holds
special status as being _the_ standard way to express dates in JSON. Both
ES4 and Crockford/json.org's library have standardized on this format for
dates, and I think it will and should be primary usage for dates. It is
highly beneficial to have one single format for communicating a
date/timestamp, for simplicity and interoperability, and due to the
JavaScript's choice of Date as the name of it's timestamp class (and other
languages do the same), it seems to like having the most obvious name "date"
equate to the primary intended usage of dates in JSON.
The "date-only" and "time" formats only exist for special cases where you
absolutely have to transport only a date part or only a time part, and
therefore I think they should have less "honorable" names. Maybe I should
change "time" -> "time-only".
Does that make sense?

SMM

unread,
Jan 8, 2008, 7:25:10 PM1/8/08
to JSON Schema
I understand the reasoning, but I think that since ES4 doesn't have a
data type for just date or just time, they didn't bother to
differentiate. I personally think that there is plenty of precedence
for "date-time". e.g., XML Schema lists "dateTime", "date", and
"time" in the list of primitives:

http://www.w3.org/TR/xmlschema11-2/#built-in-primitive-datatypes

The schema types don't necessarily have to match up to JavaScript type
nomenclature. In fact, none of the other types are actual ES4/JSON
types. I think intuitive and clean naming goes a long way.

Thanks,
Stephen
> > > What about "datetime"?- Hide quoted text -
>
> - Show quoted text -

Kris Zyp

unread,
Jan 8, 2008, 7:37:18 PM1/8/08
to json-...@googlegroups.com
The clarity and precedence of XML schema is compelling. I could change it.
Anybody else have any thoughts?

SMM

unread,
Jan 8, 2008, 7:43:19 PM1/8/08
to JSON Schema
Not to beat a dead horse but a quick Google search seems to show that
Java and JavaScript are the exception rather than the rule for use of
"Date" rather than "DateTime":

XML Schema
http://www.w3.org/TR/xmlschema-2/#isoformats

Microformats
http://microformats.org/wiki/datetime-design-pattern

C#
http://msdn2.microsoft.com/en-us/library/system.datetime.aspx

Ruby
http://ruby-doc.org/core/classes/DateTime.html

T-SQL
http://technet.microsoft.com/en-us/library/ms187819.aspx

MySQL
http://dev.mysql.com/doc/refman/6.0/en/datetime.html

PHP
http://www.php.net/datetime

Perl
http://datetime.perl.org/?Modules

Python
http://docs.python.org/lib/datetime-datetime.html
> > - Show quoted text -- Hide quoted text -

Weston Ruter

unread,
Jan 8, 2008, 9:01:13 PM1/8/08
to json-...@googlegroups.com
I agree that DateTime is a better choice over Date.
On Jan 8, 2008 4:43 PM, SMM <jso...@gmail.com> wrote:

Kris Zyp

unread,
Jan 8, 2008, 9:03:16 PM1/8/08
to json-...@googlegroups.com
Ok, you win :) I changed the proposal. I used "date-time". Is there another
capitilization format that you would prefer like "dateTime"? Also, I did
include wording to indicate that "date-time" is the preferred date/time
format. Also, do you think I should add the other XML Schema date types
gYearMonth, gYear, gMonthDay, gDay, gMonth as formats?

Claudio D'angelo

unread,
Jan 9, 2008, 2:39:33 AM1/9/08
to json-...@googlegroups.com
For my experience datetime, date and time are enough at this time but
for the future this can be inserted in specification.

Can we achieve a first version of json schema specification?
I think it's better supply first information to use normal formats (int,
string, date, float, etc...)


Kris Zyp ha scritto:

Jakob Kruse

unread,
Jan 23, 2008, 1:18:29 PM1/23/08
to JSON Schema
I vote for "datetime" or "dateTime" over "date-time".

Now that we've established that following EcmaScript is not always
necessary or optimal (which I agree with), there's one other "problem"
with dates. Having a single recommended date format is A Good
Thing(TM). Being unable to describe other date formats is not!

There are cases where one needs to transport a date (or datetime) in a
JSON structure, but doesn't care enough about the format of said date
to want to convert the format back and forth. Oracle is an example of
a database that produces datetime strings that are different from the
format recommended here (do note that ISO8601 specifies a handful of
"recommended formats" of which you seem to have chosen just one,
Oracle another). When making a Schema describing a structure including
such a date, it is still - for documentation - extremely important to
be able to accurately describe the format. The current proposal
doesn't allow for that in anything other that prose.

Would it be impossible to include a "mask" attribute, in which one
could supply a date/time mask, using predefined characters from some
set? The only other possibility is using a regular expression, and
that's neither fulfilling nor readable.

Were it up to me, I would include "datetime" as a "type", not as a
"format", because that's what it is in 90% of the programming
languages slash databases for which JSON makes sense. A "mask"
attribute would then only be applicable for "datetime" types. That
makes more sense than only making it applicable for strings with a
"datetime" format.

/Jakob

PS: In some cases one would also want to format a date/time on the
server as it should be displayed on the client - again, non-
recommended, but important to be able to do it, and describe it in an
easy-to-read manner.


On Jan 9, 3:03 am, "Kris Zyp" <kris...@gmail.com> wrote:
> Ok, you win :) I changed the proposal. I used "date-time". Is there another
> capitilization format that you would prefer like "dateTime"? Also, I did
> include wording to indicate that "date-time" is the preferred date/time
> format. Also, do you think I should add the other XML Schema date types
> gYearMonth, gYear, gMonthDay, gDay, gMonth as formats?
> Kris
>
> ----- Original Message -----
> From: "SMM" <jso...@gmail.com>
> To: "JSON Schema" <json-...@googlegroups.com>
> Sent: Tuesday, January 08, 2008 5:43 PM
> Subject: Re: Discussion on common-json-schema-definitions
>
> Not to beat a dead horse but a quick Google search seems to show that
> Java and JavaScript are the exception rather than the rule for use of
> "Date" rather than "DateTime":
>
> XML Schemahttp://www.w3.org/TR/xmlschema-2/#isoformats
>
> Microformatshttp://microformats.org/wiki/datetime-design-pattern
>
> C#http://msdn2.microsoft.com/en-us/library/system.datetime.aspx
>
> Rubyhttp://ruby-doc.org/core/classes/DateTime.html
>
> T-SQLhttp://technet.microsoft.com/en-us/library/ms187819.aspx
>
> MySQLhttp://dev.mysql.com/doc/refman/6.0/en/datetime.html
>
> PHPhttp://www.php.net/datetime
>
> Perlhttp://datetime.perl.org/?Modules
>
> Pythonhttp://docs.python.org/lib/datetime-datetime.html
Reply all
Reply to author
Forward
0 new messages