On 24 January 2016, Bram Moolenaar <b...@moolenaar.net> wrote: > > 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. [...] > > 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. /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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.