diff --git a/src/json.c b/src/json.c index 928825e034..3aa6be7212 100644 --- a/src/json.c +++ b/src/json.c @@ -46,12 +46,14 @@ DEF_DLL_FN (size_t, json_array_size, (const json_t *array)); DEF_DLL_FN (json_t *, json_object, (void)); DEF_DLL_FN (int, json_object_set_new, (json_t *object, const char *key, json_t *value)); +DEF_DLL_FN (int, json_object_set_new_nocheck, + (json_t *object, const char *key, json_t *value)); DEF_DLL_FN (json_t *, json_null, (void)); DEF_DLL_FN (json_t *, json_true, (void)); DEF_DLL_FN (json_t *, json_false, (void)); DEF_DLL_FN (json_t *, json_integer, (json_int_t value)); DEF_DLL_FN (json_t *, json_real, (double value)); -DEF_DLL_FN (json_t *, json_stringn, (const char *value, size_t len)); +DEF_DLL_FN (json_t *, json_stringn_nocheck, (const char *value, size_t len)); DEF_DLL_FN (char *, json_dumps, (const json_t *json, size_t flags)); DEF_DLL_FN (int, json_dump_callback, (const json_t *json, json_dump_callback_t callback, void *data, @@ -97,12 +99,13 @@ init_json_functions (void) LOAD_DLL_FN (library, json_array_size); LOAD_DLL_FN (library, json_object); LOAD_DLL_FN (library, json_object_set_new); + LOAD_DLL_FN (library, json_object_set_new_nocheck); LOAD_DLL_FN (library, json_null); LOAD_DLL_FN (library, json_true); LOAD_DLL_FN (library, json_false); LOAD_DLL_FN (library, json_integer); LOAD_DLL_FN (library, json_real); - LOAD_DLL_FN (library, json_stringn); + LOAD_DLL_FN (library, json_stringn_nocheck); LOAD_DLL_FN (library, json_dumps); LOAD_DLL_FN (library, json_dump_callback); LOAD_DLL_FN (library, json_integer_value); @@ -131,12 +134,13 @@ init_json_functions (void) #define json_array_size fn_json_array_size #define json_object fn_json_object #define json_object_set_new fn_json_object_set_new +#define json_object_set_new_nocheck fn_json_object_set_new_nocheck #define json_null fn_json_null #define json_true fn_json_true #define json_false fn_json_false #define json_integer fn_json_integer #define json_real fn_json_real -#define json_stringn fn_json_stringn +#define json_stringn_nocheck fn_json_stringn_nocheck #define json_dumps fn_json_dumps #define json_dump_callback fn_json_dump_callback #define json_integer_value fn_json_integer_value @@ -394,9 +398,10 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp, table test is not `equal'. */ if (json_object_get (json, key_str) != NULL) wrong_type_argument (Qjson_value_p, lisp); - int status = json_object_set_new (json, key_str, - lisp_to_json (HASH_VALUE (h, i), - conf)); + int status + = json_object_set_new_nocheck (json, key_str, + lisp_to_json (HASH_VALUE (h, i), + conf)); if (status == -1) { /* A failure can be caused either by an invalid key or @@ -508,12 +513,9 @@ lisp_to_json (Lisp_Object lisp, struct json_configuration *conf) else if (STRINGP (lisp)) { Lisp_Object encoded = json_encode (lisp); - json_t *json = json_stringn (SSDATA (encoded), SBYTES (encoded)); + json_t *json = json_stringn_nocheck (SSDATA (encoded), SBYTES (encoded)); if (json == NULL) { - /* A failure can be caused either by an invalid string or by - low memory. */ - json_check_utf8 (encoded); json_out_of_memory (); } return json;