Wednesday, December 21, 2016

Inconsistent json_encode() behaviors regarding empty (sub)strings

Hi folks,

I was trying out the new channel APIs, and found a little glitch in
the built-in function json_encode():

call assert_equal('', 'a'[1:0]) " pass
call assert_equal('""', json_encode('')) "pass
call assert_equal('""', json_encode('a'[1:0])) " fail,
json_encode(...) returns 'null'

I failed to see any content about the sub-string syntax str[a:b] in
the documents, but it seems legit for sub-lists, so I've been using it
all over my code, until encode_json('a'[1:0]) gave me 'null' as a
result.

I was running Vim version 8.0.134. Is this a bug?

Regards,
Kay. Z

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: