Re: : in the flow context for PyYAML and SnakeYAML

Kirill Simonov <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
On 08/25/2010 10:12 PM, William Spitzak wrote:
> Kirill Simonov wrote:
>
>> By unquoted JSON, do you mean something like:
>>      {foo:"bar"}
>
> Yes, though
> 	{foo: "bar"}
> is probably a better example (note the space!)
>
>> This is definitely not a valid JSON and I'm certain most of the JSON
>> parsers will fail to parse it.
>
> However there are a lot of pseudo-JSON parsers that *do* parse it,
> including libyaml itself!

A lot? Other than Javascript eval(), I'm not aware of any parser library 
that could parse it.  Python's standard json.py module certainly cannot 
do it.  Could you name some of the parsers, please?

>
> If the concern is for typing url data in, I would just change the rules
> for colon for an unquoted scaler depending on whether a key or value is
> being read in. You could even allow following spaces. The following:
>
> 	{foo:http:baz: zoo}
>
> would be interpreted as:
>
> 	{"foo" : "http:baz: zoo")
>
> It would seem that such a design is much more in keeping with the style
> of YAML.

I see two problems with this definition.

First, it complicates the YAML grammar even further by creating 3 
similar, but subtly different plain scalar styles.  The YAML grammar is 
already complex enough, I'd prefer not to have it even more complex.

Second, it creates an ambiguity in the case:
         [foo:bar] (or even [foo: bar])
which could be interpreted as
	["foo:bar"]
or as
	[{"foo": "bar"}]
depending on whether you consider `foo: bar` a single value or a key: 
value pair.


Thanks,
Kirill

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.