patch 8.0.1391: encoding empty string to JSON sometimes gives "null"
Problem: Encoding empty string to JSON sometimes gives "null".
Solution: Handle NULL string as empty string. (closes #2446)
diff --git a/src/json.c b/src/json.c
index e5e85eb..6f914ea 100644
--- a/src/json.c
+++ b/src/json.c
@@ -92,7 +92,7 @@
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 @@
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 @@
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)