Patch 8.0.1391
Problem: Encoding empty string to JSON sometimes gives "null".
Solution: Handle NULL string as empty string. (closes #2446)
Files: src/testdir/test_json.vim, src/json.c
*** ../vim-8.0.1390/src/testdir/test_json.vim 2017-02-05 16:34:39.263759703
+0100
--- src/testdir/test_json.vim 2017-12-15 21:23:41.906315516 +0100
***************
*** 103,108 ****
--- 103,112 ----
call assert_fails('echo json_encode(function("tr"))', 'E474:')
call assert_fails('echo json_encode([function("tr")])', 'E474:')
+ call assert_equal('{"a":""}', json_encode({'a': test_null_string()}))
+ call assert_equal('{"a":[]}', json_encode({"a": test_null_list()}))
+ call assert_equal('{"a":{}}', json_encode({"a": test_null_dict()}))
+
silent! let res = json_encode(function("tr"))
call assert_equal("", res)
endfunc
*** ../vim-8.0.1390/src/json.c 2017-02-05 16:34:39.263759703 +0100
--- src/json.c 2017-12-15 21:24:02.082133111 +0100
***************
*** 92,98 ****
char_u numbuf[NUMBUFLEN];
if (res == NULL)
! ga_concat(gap, (char_u *)"null");
else
{
#if defined(FEAT_MBYTE) && defined(USE_ICONV)
--- 92,98 ----
char_u numbuf[NUMBUFLEN];
if (res == NULL)
! ga_concat(gap, (char_u *)"\"\"");
else
{
#if defined(FEAT_MBYTE) && defined(USE_ICONV)
***************
*** 237,243 ****
case VAR_LIST:
l = val->vval.v_list;
if (l == NULL)
! ga_concat(gap, (char_u *)"null");
else
{
if (l->lv_copyID == copyID)
--- 237,243 ----
case VAR_LIST:
l = val->vval.v_list;
if (l == NULL)
! ga_concat(gap, (char_u *)"[]");
else
{
if (l->lv_copyID == copyID)
***************
*** 272,278 ****
case VAR_DICT:
d = val->vval.v_dict;
if (d == NULL)
! ga_concat(gap, (char_u *)"null");
else
{
if (d->dv_copyID == copyID)
--- 272,278 ----
case VAR_DICT:
d = val->vval.v_dict;
if (d == NULL)
! ga_concat(gap, (char_u *)"{}");
else
{
if (d->dv_copyID == copyID)
*** ../vim-8.0.1390/src/version.c 2017-12-14 13:15:12.722867837 +0100
--- src/version.c 2017-12-15 21:24:49.129714340 +0100
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1391,
/**/
--
hundred-and-one symptoms of being an internet addict:
102. When filling out your driver's license application, you give
your IP address.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.