[PATCH] D31992: [clangd] Escape only necessary characters in JSON output
Marc-Andre Laperle via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 16 13:21:22 PDT 2017
malaperle-ericsson added a comment.
In https://reviews.llvm.org/D31992#728036, @joerg wrote:
> Just to avoid any confusion: this should be the generic YAML escape routine in llvm/lib/Support, i.e. IMO we don't want to have separate YAML and JSON escape routines.
> Effective, change YAMLParser.cpp line 697 to use \u and drop the whole UTF-8 handling part.
I'm not sure it's possible or desirable to reuse yaml::escape as they are two formats and it's expected that a yaml output might not be able to be read by a json parser. If I look at the yaml::escape routine, there are several escape that are incompatible with JSON like \0, \v, \e, and 32-bit handling via \U.
I think ideally this patch would be a stop-gap solution until jsoncpp is introduced so that one can build json output in a structured way (as opposed to manually appending strings now) and the output will also be escape via the library.
https://reviews.llvm.org/D31992
More information about the cfe-commits
mailing list