From f84a2089298b46a2db885484a6561d6b78808240 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Wed, 18 Sep 2024 14:27:49 -0700 Subject: [PATCH] Remove deprecated Json::Reader in favor of Json::CharReader PiperOrigin-RevId: 676132312 --- conformance/binary_json_conformance_suite.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index d2d7a8871874c..ede4710cc65e3 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/strings/substitute.h" +#include "json/config.h" #include "json/reader.h" #include "json/value.h" #include "conformance/conformance.pb.h" @@ -659,12 +660,16 @@ void BinaryAndJsonConformanceSuiteImpl< suite_.ReportFailure(test, level, request, response); return; } - Json::Reader reader; + Json::CharReaderBuilder builder; Json::Value value; - if (!reader.parse(response.json_payload(), value)) { + Json::String err; + const std::unique_ptr reader(builder.newCharReader()); + if (!reader->parse( + response.json_payload().c_str(), + response.json_payload().c_str() + response.json_payload().length(), + &value, &err)) { test.set_failure_message( - absl::StrCat("JSON payload cannot be parsed as valid JSON: ", - reader.getFormattedErrorMessages())); + absl::StrCat("JSON payload cannot be parsed as valid JSON: ", err)); suite_.ReportFailure(test, level, request, response); return; }