Lcd wrote:

> [...]
> > > > >     One more thing: adjusting the result of jsondecode() to contain
> > > > > only "standard" values involves deep traversal, which is not
> > > > > trivial.  Actually, it's pretty hard to get right.
> > > >
> > > > Example?
> > > 
> > >     Anything nested would do:
> > > 
> > > :echo jsondecode('[{"a":true, "b":false}, null, {"foo": true, "bar": 
> > > true, "baz": null}]')
> > > [{'a': true, 'b': false}, null, {'foo': true, 'baz': null, 'bar': true}]
> > > 
> > >     Replacing all true, false, and null with "plain" 0, 1, and ''
> > > means traversing the leaves of this.
> >
> > When would that be needed? v:true and v:false can be used in an
> > expression just like one and zero.  I don't know what to replace
> > v:null with, it must be recognized to know there is nothing there.  In
> > this example an empty dict is probably what you want, but that's not a
> > generic solution.
> 
>     There are situations where what is needed is to extract different
> things from a large JSON and do something with the values.  Having to
> make a difference between, say, v:true and 1 would propagate all over
> the place, because:
> 
>         :echo v:true == 1
>         1
> 
> but
> 
>         :echo [v:true] == [1]
>         0

This is unexpected, but the same happens for other items with a similar
value but different type:
         :echo 1.0 == 1
         1
         :echo [1.0] == [1]
         0

Perhaps we should change that as well?  It is related to, for example,
index():
        echo index([0, v:false], v:false)
        echo index([1.0, 1], 1)

Should these return 0 or 1?

We can make it work differently for when using ==.  That sort of makes
sense, even though it's not completely consistent.

> and
> 
>         :echo [v:true] is [1]
>         0

That is correct, even:
         :echo [1] is [1]
         0

-- 
The users that I support would double-click on a landmine to find out
what happens.                           -- A system administrator

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui