summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/json.c b/src/json.c
index d9da10d35..d8ccfe8fb 100644
--- a/src/json.c
+++ b/src/json.c
@@ -195,8 +195,10 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
{
char_u numbuf[NUMBUFLEN];
char_u *res;
+ blob_T *b;
list_T *l;
dict_T *d;
+ int i;
switch (val->v_type)
{
@@ -233,6 +235,25 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
EMSG(_(e_invarg));
return FAIL;
+ case VAR_BLOB:
+ b = val->vval.v_blob;
+ if (b == NULL || b->bv_ga.ga_len == 0)
+ ga_concat(gap, (char_u *)"[]");
+ else
+ {
+ ga_append(gap, '[');
+ for (i = 0; i < b->bv_ga.ga_len; i++)
+ {
+ if (i > 0)
+ ga_concat(gap, (char_u *)",");
+ vim_snprintf((char *)numbuf, NUMBUFLEN, "%d",
+ (int)blob_get(b, i));
+ ga_concat(gap, numbuf);
+ }
+ ga_append(gap, ']');
+ }
+ break;
+
case VAR_LIST:
l = val->vval.v_list;
if (l == NULL)