XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Pete's blend for XMLlite

Original Message From: "Michael Kay"

> One thing I'd like to bring in from the JSON world is some basic duck 
> typing.
>
> <person age=90 dob=1920-03-04 name="Ronald" retired=true 
> children=["Barbara", "Michael"]/>
>
> There's no need for a DTD or schema to do simple type annotation.


I'm not convinced that the typing in JSON is a key feature.  If you don't 
know what a 'wibble' is, knowing it is an integer doesn't really help you 
much.  I think it's an artifact of JSON being based on Javascript that it 
has these different forms for integers vs. strings etc.  A program does need 
to know whether something is an integer.  A transfer format just needs to 
get across the wire some suitable representation of wibble that a program 
can use.  As part of knowing how to deal with a wibble, the program knows 
that a wibble is an integer.

I would say your sample is fairly exlicit typing.  (I guess there is 
ambiguity around whether 'age' is an integer, float or decimal.)  But I 
think duck typing would work pretty much as well if you had regular XML:

<person age='90' dob='1920-03-04' name="Ronald" retired='true'
children='["Barbara", "Michael"]'/>

In the case of Javascript it would be sensible to duck type age to a number 
as it doesn't need much provocation to convert a number to a string.  For 
example:

var json = { "Int" : 12, "Int2" : 14 };
var result = "The sum is: " + json.Int + json.Int2;
document.write( result );

yields:

The sum is: 1214

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS