W3C home > Mailing lists > Public > public-linked-json@w3.org > September 2011

RE: Type Coercion is confusing (ISSUE-34)

From: Markus Lanthaler <markus.lanthaler@gmx.net>
Date: Thu, 29 Sep 2011 11:34:01 +0200
To: <public-linked-json@w3.org>
Cc: "'Gregg Kellogg'" <gregg@kellogg-assoc.com>
Message-ID: <000b01cc7e8a$ed32ae50$c7980af0$@lanthaler@gmx.net>
> In fact, my internal representation is what you suggest. The rationale
> for the existing rep is that it is much shorter, otherwise a given type
> would need to be specified once for each property.

Yes, that's true. Of course you could also see it as a variable declaration
such as "int age, height". Nevertheless I find it confusing and see it as a
source of a lot of hard-to-debug errors.

It's much easier to check what the type of an attribute is if it's stored
the other way round. It's also easier to prevent people setting the type of
an attribute to two incompatible types (copy and paste/inconsistent changes)
such as:

 "xsd:integer": ["age", "value", "size" ],
 "@iri": "homepage",
 .. a lot of other stuff ..
 "xsd:boolean": ["read", "deleted", "value"]

It's really difficult to spot that "value" is coerced to both, xsd:integer
and xsd:boolean. No one would miss such an error in the other form:

  "value": [ "xsd:integer", "xsd:boolean" ]

So I would really like to change this form. The few bytes we save here
shouldn't really matter that much; I reckon GZIP eliminates most of the
overhead anyway.

Markus Lanthaler
Received on Thursday, 29 September 2011 09:34:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:53:18 UTC