diff options
| author | Philipp Stephani | 2017-12-19 00:04:29 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2017-12-24 13:52:30 +0100 |
| commit | 3455192777459a08a38b0adb311a76202e29f48d (patch) | |
| tree | aa20b6d6b54940814ee6dd2775b2b440333385ce /test/src | |
| parent | c7a50740273a338285abe7c9bb24a1f45928e02a (diff) | |
| download | emacs-3455192777459a08a38b0adb311a76202e29f48d.tar.gz emacs-3455192777459a08a38b0adb311a76202e29f48d.zip | |
JSON serialization: reject duplicate keys in hashtables
* src/json.c (lisp_to_json_toplevel_1): Reject duplicate keys in
hashtables.
* test/src/json-tests.el (json-serialize/object-with-duplicate-keys):
Add unit tests.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/json-tests.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el index 9884e9a2d57..5d9f6b3840c 100644 --- a/test/src/json-tests.el +++ b/test/src/json-tests.el | |||
| @@ -52,6 +52,14 @@ | |||
| 52 | (should (equal (json-serialize table) | 52 | (should (equal (json-serialize table) |
| 53 | "{\"abc\":[1,2,true],\"def\":null}")))) | 53 | "{\"abc\":[1,2,true],\"def\":null}")))) |
| 54 | 54 | ||
| 55 | (ert-deftest json-serialize/object-with-duplicate-keys () | ||
| 56 | (skip-unless (fboundp 'json-serialize)) | ||
| 57 | (let ((table (make-hash-table :test #'eq))) | ||
| 58 | (puthash (copy-sequence "abc") [1 2 t] table) | ||
| 59 | (puthash (copy-sequence "abc") :null table) | ||
| 60 | (should (equal (hash-table-count table) 2)) | ||
| 61 | (should-error (json-serialize table) :type 'wrong-type-argument))) | ||
| 62 | |||
| 55 | (ert-deftest json-parse-string/object () | 63 | (ert-deftest json-parse-string/object () |
| 56 | (skip-unless (fboundp 'json-parse-string)) | 64 | (skip-unless (fboundp 'json-parse-string)) |
| 57 | (let ((input | 65 | (let ((input |