Subject: Re: Structured data over TCP?

From: Paul Hoffman <[email-masked]>
Date: Sun, 31 May 2009 18:24:16 -0700

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.

---

From: Patrik Fältström <[email-masked]>
Date: Mon, 1 Jun 2009 08:36:15 +0200

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

> 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