patch 8.1.1734: the evalfunc.c file is too big
Problem: The evalfunc.c file is too big.
Solution: Move some functions to other files.
diff --git a/src/json.c b/src/json.c
index 3a5de70..c9a6230 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1127,3 +1127,52 @@
return ret;
}
#endif
+
+/*
+ * "js_decode()" function
+ */
+ void
+f_js_decode(typval_T *argvars, typval_T *rettv)
+{
+ js_read_T reader;
+
+ reader.js_buf = tv_get_string(&argvars[0]);
+ reader.js_fill = NULL;
+ reader.js_used = 0;
+ if (json_decode_all(&reader, rettv, JSON_JS) != OK)
+ emsg(_(e_invarg));
+}
+
+/*
+ * "js_encode()" function
+ */
+ void
+f_js_encode(typval_T *argvars, typval_T *rettv)
+{
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = json_encode(&argvars[0], JSON_JS);
+}
+
+/*
+ * "json_decode()" function
+ */
+ void
+f_json_decode(typval_T *argvars, typval_T *rettv)
+{
+ js_read_T reader;
+
+ reader.js_buf = tv_get_string(&argvars[0]);
+ reader.js_fill = NULL;
+ reader.js_used = 0;
+ json_decode_all(&reader, rettv, 0);
+}
+
+/*
+ * "json_encode()" function
+ */
+ void
+f_json_encode(typval_T *argvars, typval_T *rettv)
+{
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = json_encode(&argvars[0], 0);
+}