GNU bug report logs -
#50391
28.0.50; json-read non-ascii data results in malformed string
Previous Next
Reported by: Zhiwei Chen <condy0919 <at> gmail.com>
Date: Sun, 5 Sep 2021 04:21:02 UTC
Severity: normal
Tags: notabug
Found in version 28.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Am 05.09.2021 um 06:19 schrieb Zhiwei Chen <condy0919 <at> gmail.com>:
>
>
> When fetch json from youdao (a dict service in China).
>
> #+begin_src elisp
> (url-retrieve
> "https://dict.youdao.com/suggest?q=accumulate&le=eng&num=80&doctype=json"
> (lambda (_status)
> (goto-char (1+ url-http-end-of-headers))
> (write-region (point) (point-max) "/tmp/acc1.json")))
> #+end_src
>
> Then C-x C-f "/tmp/acc1.json", the file is correctly encoded without
>
> But If `json-read' then `json-insert', the file is malformed even if
> uchardet shows the encoding of the file is utf-8.
>
> #+begin_src elisp
> (url-retrieve
> "https://dict.youdao.com/suggest?q=accumulate&le=eng&num=80&doctype=json"
> (lambda (_status)
> (goto-char (1+ url-http-end-of-headers))
> (let ((j (json-read)))
> (with-temp-buffer
> (json-insert j)
> (write-region (point-min) (point-max) "/tmp/acc2.json")))))
> #+end_src
Does it work if you use the C JSON function (json-parse-buffer) for parsing? At least for me the two files are then identical.
This bug report was last modified 3 years and 319 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.