On 24 January 2016, Bram Moolenaar <[email protected]> wrote:
> 
> 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

and

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

    /lcd

-- 
-- 
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