> + ;; Special-case UTF-16 surrogate pairs,
> + ;; cf. https://tools.ietf.org/html/rfc7159#section-7. Note that
> + ;; this clause overlaps with the next one and therefore has to
> + ;; come first.
> + ((looking-at
> + (rx (group (any "Dd") (any "89ABab") (= 2 (any "0-9A-Fa-f")))
> + "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any "0-9A-Fa-f")))))
> + (json-advance 10)
> + (json--decode-utf-16-surrogates
> + (string-to-number (match-string 1) 16)
> + (string-to-number (match-string 2) 16)))
> ((looking-at "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]")
Wouldn't it be better to move the surrogate-handling into the
hex-handling branch?
Maybe, I don't have a strong preference. The current solution avoids an additional nested conditional though.