[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 13 07:21:36 PDT 2017


klimek added a comment.

In https://reviews.llvm.org/D31992#725912, @malaperle-ericsson wrote:

> In https://reviews.llvm.org/D31992#725866, @krasimir wrote:
>
> > Seems that we're starting to hit some YAML/JSON mismatches, or is it that your YAML string support is lacking?
>
>
> I don't think so. It seems like JSON and YAML are not completely aligned on escaped characters. See http://yaml.org/spec/1.2/spec.html#id2776092 which specifies unicode 8, 16, and 32 bits are escaped with \x, \u, and \U whereas http://www.json.org/string.gif specifies that unicode 16 bit characters can be encoded with \u but \x and \U are not supported. This leads me to believe that a YAML parser can read JSON but a JSON parser will not necessarily be able to read YAML. I thought about using json cpp but that's a much bigger change


Here we only talk about what we escape, which should be the minimum required.
If I understand correctly, that's " and \ for JSON and ", \ and all non-printable characters (which unfortunately requires understanding of unicode to solve this fully correctly) in YAML.
Am I missing something?


Repository:
  rL LLVM

https://reviews.llvm.org/D31992





More information about the cfe-commits mailing list