Paul Hoffman | 1 Jun 03:24
Picon

Re: Structured data over TCP?

At 12:50 PM -0500 5/29/09, Nicolas Williams wrote:
>Therefore, if you have a volatile API then you need to have a way to do
>versioning if you use JSON.  Then again, if you have data that has a
>long at-rest lifetime, then you really want to specify its schema
>somewhere, and once you're at that point you're better off with XML.

What is the problem with starting your JSON with a string that identifies the schema? { {"uid" : "97ad72a2"}
{ "count" : 42 } .... }. A parser can look for the first item in the structure and be sure that it exactly
matches what it expects.
Patrik Fältström | 1 Jun 08:36
Picon
Favicon

Re: Structured data over TCP?

On 1 jun 2009, at 03.24, Paul Hoffman wrote:

> At 12:50 PM -0500 5/29/09, Nicolas Williams wrote:
>> Therefore, if you have a volatile API then you need to have a way  
>> to do
>> versioning if you use JSON.  Then again, if you have data that has a
>> long at-rest lifetime, then you really want to specify its schema
>> somewhere, and once you're at that point you're better off with XML.
>
> What is the problem with starting your JSON with a string that  
> identifies the schema? { {"uid" : "97ad72a2"} { "count" :  
> 42 } .... }. A parser can look for the first item in the structure  
> and be sure that it exactly matches what it expects.

Even easier, you can have:

{ 'version' : 4711, 'data' : { 'foo' : 11, 'bar' : 'cookie' }}

And then check for "version". And if "version" does not exist, bail.

    paf

Gmane