[vim] jsonencode() silently converts recursive containers into empty (#586)

26 views
Skip to first unread message

Nikolai Aleksandrovich Pavlov

unread,
Jan 23, 2016, 7:55:40 PM1/23/16
to vim/vim

Consider the following script:

vim -u NONE --cmd 'let l=[]' --cmd 'call add(l, l)' --cmd 'echo jsonencode(l)'

This will echo [[]], but actually it should error out because recursive container cannot be represented in JSON.


Reply to this email directly or view it on GitHub.

Bram Moolenaar

unread,
Jan 24, 2016, 10:50:16 AM1/24/16
to vim/vim

Nikolai Aleksandrovich Pavlov wrote:

> Consider the following script:
>
> vim -u NONE --cmd 'let l=[]' --cmd 'call add(l, l)' --cmd 'echo jsonencode(l)'
>
> This will echo [[]], but actually it should error out because
> recursive container cannot be represented in JSON.

Yeah, another case of either falling back to something or producing an
error. I assume nobody wants to intentionally convert a recursive
structure into JSON. OK, let's make that an error.

--
hundred-and-one symptoms of being an internet addict:
31. You code your homework in HTML and give your instructor the URL.

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

unread,
Jun 28, 2016, 4:33:00 PM6/28/16
to vim/vim

Closed #586.


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

Christian Brabandt

unread,
Jun 28, 2016, 4:33:00 PM6/28/16
to vim/vim

seems to be fixed.

Reply all
Reply to author
Forward
0 new messages