Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsondecode() parses incorrect JSON #593

Closed
ZyX-I opened this issue Jan 24, 2016 · 2 comments
Closed

jsondecode() parses incorrect JSON #593

ZyX-I opened this issue Jan 24, 2016 · 2 comments

Comments

@ZyX-I
Copy link

ZyX-I commented Jan 24, 2016

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.

@ZyX-I
Copy link
Author

ZyX-I commented Jan 24, 2016

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

@brammool
Copy link
Contributor

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 -- Bram@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 ///

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants