Lcd wrote:
> [...]
> > > Actually, since you added two more values for type(), it would
> > > make sense to make Bool and Null standard types, Vim citizens with
> > > full rights. But some careful consideration would be needed for the
> > > interaction with the other types, so that they can also be used for
> > > other purposes, unrelated to JSON.
> >
> > The thing is that the only valid values are what we have now. Giving
> > those types a name doesn't really help.
> >
> > > The alternative would be to make jsondecode() return only
> > > standard Vim values (that is, true --> 1, false --> 0, null --> ''),
> > > and leave v:<special> only for encoding. Less powerful, but a lot
> > > simpler, and a lot more robust.
> >
> > Then you can't tell the difference between decoding a zero or "false".
> > This drops information that might be important. I'm sure this will be
> > a problem at a later time.
>
> Yes, but now we have the worst of the two worlds: types that aren't
> quite types, and values that aren't quite values. They'll break things
> eventually. Actually, Nikolai Aleksandrovich Pavlov has a few examples
> when they do. F.i. eval(string(var)) is no longer guaranteed to be the
> same as var.
Well, using an existing type that won't work either.
I suppose string(v:false) could return "v:false" instead of "false",
then it works. I wonder if that causes new problems though.
> [...]
> > > This is still somewhat inconsistent:
> > >
> > > :echo jsondecode('{"a":}')
> > > E474: Invalid argument
> > > {'a': none}
> > >
> > > A better way to deal with this might be to find a JSON linter /
> > > validator / pretty printer with tests, and run said tests in Vim.
> >
> > We can easily add more JSON examples in the test_json.vim test.
> [...]
>
> My point is not that there aren't enough tests. What I'm saying
> is that Vim doesn't do proper validation, and it doesn't return a
> well-defined condition when it finds errors. Basically the behaviour of
> jsondecode(val) is undefined if val is not valid JSON, and in most cases
> that isn't useful.
The error messages can be improved to tell you where the problem is.
That's a bit of work though. The goal is not to write a JSON validator,
but to make it possible to communicate with other languages.
--
hundred-and-one symptoms of being an internet addict:
32. You don't know what sex three of your closest friends are, because they
have neutral nicknames and you never bothered to ask.
/// 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.