summaryrefslogtreecommitdiffstats
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c
index db25b70cc4..d0a087a927 100644
--- a/src/json.c
+++ b/src/json.c
@@ -607,7 +607,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
cur_item = res;
init_tv(&item);
if (res != NULL)
- init_tv(res);
+ init_tv(res);
fill_numbuflen(reader);
p = reader->js_buf + reader->js_used;
@@ -920,6 +920,15 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
&& cur_item != NULL)
{
+#ifdef FEAT_FLOAT
+ if (cur_item->v_type == VAR_FLOAT)
+ {
+ // cannot use a float as a key
+ emsg(_(e_float_as_string));
+ retval = FAIL;
+ goto theend;
+ }
+#endif
top_item->jd_key = tv_get_string_buf_chk(cur_item, key_buf);
if (top_item->jd_key == NULL)
{