[clang-tools-extra] [clang-doc] Add option for compact JSON (PR #190822)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 15:25:27 PDT 2026
================
@@ -915,7 +915,10 @@ Error JSONGenerator::serializeIndex(StringRef RootDir) {
raw_fd_ostream RootOS(IndexFilePath, FileErr, sys::fs::OF_Text);
if (FileErr)
return createFileError("cannot open file " + IndexFilePath, FileErr);
- RootOS << llvm::formatv("{0:2}", ObjVal);
+ if (CDCtx->CompactJSON)
+ RootOS << llvm::formatv("{0}", ObjVal);
+ else
+ RootOS << llvm::formatv("{0:2}", ObjVal);
----------------
ilovepi wrote:
ah, looking, I think it may be a bit harder than I led on. we normally use the ostream to construct the json, but we already have values we're manipulating, and Json::Ostream is best for generating json objects efficiently, without making intermediate values. we may want to consider using it to build the values we need in the future, but for now, lets just go with what you have. If I'm really annoyed, then I can write a thin wrapper around the formatting bits.
https://github.com/llvm/llvm-project/pull/190822
More information about the cfe-commits
mailing list