[nama] JSON: (was Re: Re: Singleton branch passes all tests)

  • From: Joel Roth <joelz@xxxxxxxxx>
  • To: nama@xxxxxxxxxxxxx
  • Date: Tue, 13 Sep 2011 00:32:02 -1000

Hi all,

The short story is that JSON is technically superior to YAML: JSON's
spec is very brief, the spec is more stable than YAML, and I recall
reading that JSON handles Unicode issues better than YAML.

We were already bitten once by a change in YAML::Tiny, where a
bare string suddenly had to be single-quoted.

JSON is is fast (implemented in Perl XS), can easily handle the 
large effects cache that YAML::Tiny chokes on.

Currently the effects cache is the binary output by nstore,
a serialization function that is part of the Perl language.

Another serialization library in the running is
Data::Dumper::Concise, which outputs pretty perl code, and can even
output the deparsed code of anonymous subroutines.

I think YAML::Tiny wins as a display format. 

Negative about JSON is that it will increase my lifetime exposure to
quotation marks. Also, I wish the keys could be output in alphabetical
order. That would be convenient and would be in common with YAML.

I may write files in both formats. One for the user to read, one to
be machine readable. It doesn't cost us much
while gives us both the robustness of JSON and legibility of YAML.

What if users wanted to be able to edit the YAML file?
We could preferentially load an altered version. 

Compared to XML, the elephant in the room. JSON is much better. 

Cheers,

Joel

 
> Here is a sample of what it looks like:
> 
> nama> eval json_out $config->{devices}
> {
>    "consumer" : {
>       "ecasound_id" : "alsa,default",
>       "input_format" : "s16_le,2,44100,i",
>       "output_format" : "s16_le,2,44100,i"
>    },
>    "jack" : {
>       "signal_format" : "f32_le,N,44100"
>    },
>    "multi" : {
>       "ecasound_id" : "alsa,ice1712",
>       "input_format" : "s32_le,12,44100",
>       "output_format" : "s32_le,10,44100"
>    },
>    "null" : {
>       "ecasound_id" : "null"
>    }
> }
> 
> JSON is superior to YAML. It is a simpler spec,
> stable, and much more robust.
> 
> I am likely to keep YAML for .namarc and
> for dumping internal data structures.
> 
> Cheers,
> -- 
> Joel Roth
> 

-- 
Joel Roth

Other related posts: