diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-12-15 21:25:01 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-12-15 21:25:01 +0100 |
commit | b29d328eb403a243431f4d0d5b360b4ac46bbc3e (patch) | |
tree | 9f854ad29aa20a0375794c6189e997d4eb08d2fb /src/json.c | |
parent | 4697399e8c805325009351a2488e3da530d0af38 (diff) | |
download | vim-git-b29d328eb403a243431f4d0d5b360b4ac46bbc3e.tar.gz |
patch 8.0.1391: encoding empty string to JSON sometimes gives "null"v8.0.1391
Problem: Encoding empty string to JSON sometimes gives "null".
Solution: Handle NULL string as empty string. (closes #2446)
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c index e5e85eb6d..6f914ea03 100644 --- a/src/json.c +++ b/src/json.c @@ -92,7 +92,7 @@ write_string(garray_T *gap, char_u *str) char_u numbuf[NUMBUFLEN]; if (res == NULL) - ga_concat(gap, (char_u *)"null"); + ga_concat(gap, (char_u *)"\"\""); else { #if defined(FEAT_MBYTE) && defined(USE_ICONV) @@ -237,7 +237,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options) case VAR_LIST: l = val->vval.v_list; if (l == NULL) - ga_concat(gap, (char_u *)"null"); + ga_concat(gap, (char_u *)"[]"); else { if (l->lv_copyID == copyID) @@ -272,7 +272,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options) case VAR_DICT: d = val->vval.v_dict; if (d == NULL) - ga_concat(gap, (char_u *)"null"); + ga_concat(gap, (char_u *)"{}"); else { if (d->dv_copyID == copyID) |