From 7b7e9c162c55576c00cf7b12b0a62c83017f318d Mon Sep 17 00:00:00 2001 From: Tyler Yankee Date: Fri, 31 Jul 2026 09:43:55 -0400 Subject: [PATCH] VS: Use cmJSONState to read vswhere output This approach will be more portable. --- Source/cmVSSetupHelper.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 342b4f7b00..a016de674a 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -2,16 +2,17 @@ file LICENSE.rst or https://cmake.org/licensing for details. */ #include "cmVSSetupHelper.h" +#include #include #if !defined(CMAKE_BOOTSTRAP) -# include # include #endif #include "cmsys/Encoding.hxx" #include "cmsys/FStream.hxx" +#include "cmJSONState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -340,14 +341,10 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithVswhere( } // Parse JSON output and iterate over elements - Json::CharReaderBuilder builder; - auto jsonReader = std::unique_ptr(builder.newCharReader()); Json::Value json; - std::string error; - - if (!jsonReader->parse(json_output.data(), - json_output.data() + json_output.size(), &json, - &error)) { + std::istringstream iss(json_output); + cmJSONState parseState(iss, &json, cmJSONState::StrictMode::Relaxed); + if (!parseState.errors.empty()) { return false; }