[vim] jsondecode() parses incorrect JSON (#593)

21 visualizzazioni
Passa al primo messaggio da leggere

Nikolai Aleksandrovich Pavlov

da leggere,
24 gen 2016, 10:40:2324/01/16
a vim/vim

With Vim 7.4.1165 try jsondecode('[,]'). This will produce [v:none], but this string is not a correct JSON. jsondecode('[1,]') produces [1], but JSON spec does not allow trailing commas. jsondecode('{1: 1,}') produces {'1': 1}, but JSON spec does not allow non-string keys or trailing comma.


Reply to this email directly or view it on GitHub.

Nikolai Aleksandrovich Pavlov

da leggere,
24 gen 2016, 10:41:5024/01/16
a vim/vim

Also jsondecode('1.') produces 1.0, but JSON spec does not allow omitting number after decimal point.

Bram Moolenaar

da leggere,
24 gen 2016, 11:54:1024/01/16
a vim/vim

Nikolai Pavlov wrote:

> With Vim 7.4.1165 try `jsondecode('[,]')`. This will produce

> `[v:none]`, but this string is not a correct JSON.
> `jsondecode('[1,]')` produces `[1]`, but JSON spec does not allow
> trailing commas. `jsondecode('{1: 1,}')` produces `{'1': 1}`, but JSON
> spec does not allow non-string keys or trailing comma.

jsondecode() allows for a bit more than the standard. I'll update the
documentation. This takes it a bit in the direction of what JavaScript
eval() does.

--
Have you heard about the new Beowulf cluster? It's so fast, it executes
an infinite loop in 6 seconds.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Christian Brabandt

da leggere,
28 giu 2016, 16:32:0028/06/16
a vim/vim

Closed #593.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi