aboutsummaryrefslogtreecommitdiffstats
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/json.c b/src/json.c
index d05f2c54e2c..5a3d0012f0a 100644
--- a/src/json.c
+++ b/src/json.c
@@ -361,28 +361,31 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp,
361 count = SPECPDL_INDEX (); 361 count = SPECPDL_INDEX ();
362 record_unwind_protect_ptr (json_release_object, json); 362 record_unwind_protect_ptr (json_release_object, json);
363 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) 363 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
364 if (!NILP (HASH_HASH (h, i))) 364 {
365 { 365 Lisp_Object key = HASH_KEY (h, i);
366 Lisp_Object key = json_encode (HASH_KEY (h, i)); 366 if (!EQ (key, Qunbound))
367 /* We can't specify the length, so the string must be 367 {
368 Lisp_Object ekey = json_encode (key);
369 /* We can't specify the length, so the string must be
368 NUL-terminated. */ 370 NUL-terminated. */
369 check_string_without_embedded_nuls (key); 371 check_string_without_embedded_nuls (ekey);
370 const char *key_str = SSDATA (key); 372 const char *key_str = SSDATA (ekey);
371 /* Reject duplicate keys. These are possible if the hash 373 /* Reject duplicate keys. These are possible if the hash
372 table test is not `equal'. */ 374 table test is not `equal'. */
373 if (json_object_get (json, key_str) != NULL) 375 if (json_object_get (json, key_str) != NULL)
374 wrong_type_argument (Qjson_value_p, lisp); 376 wrong_type_argument (Qjson_value_p, lisp);
375 int status = json_object_set_new (json, key_str, 377 int status
376 lisp_to_json (HASH_VALUE (h, i), 378 = json_object_set_new (json, key_str,
377 conf)); 379 lisp_to_json (HASH_VALUE (h, i), conf));
378 if (status == -1) 380 if (status == -1)
379 { 381 {
380 /* A failure can be caused either by an invalid key or 382 /* A failure can be caused either by an invalid key or
381 by low memory. */ 383 by low memory. */
382 json_check_utf8 (key); 384 json_check_utf8 (ekey);
383 json_out_of_memory (); 385 json_out_of_memory ();
384 } 386 }
385 } 387 }
388 }
386 } 389 }
387 else if (NILP (lisp)) 390 else if (NILP (lisp))
388 return json_check (json_object ()); 391 return json_check (json_object ());