Remove deprecated Json::Reader in favor of Json::CharReader

PiperOrigin-RevId: 676132312
pull/18384/head
Sandy Zhang 2 months ago committed by Copybara-Service
parent 5da098b8b0
commit f84a208929
  1. 13
      conformance/binary_json_conformance_suite.cc

@ -26,6 +26,7 @@
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "json/config.h"
#include "json/reader.h" #include "json/reader.h"
#include "json/value.h" #include "json/value.h"
#include "conformance/conformance.pb.h" #include "conformance/conformance.pb.h"
@ -659,12 +660,16 @@ void BinaryAndJsonConformanceSuiteImpl<
suite_.ReportFailure(test, level, request, response); suite_.ReportFailure(test, level, request, response);
return; return;
} }
Json::Reader reader; Json::CharReaderBuilder builder;
Json::Value value; Json::Value value;
if (!reader.parse(response.json_payload(), value)) { Json::String err;
const std::unique_ptr<Json::CharReader> 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( test.set_failure_message(
absl::StrCat("JSON payload cannot be parsed as valid JSON: ", absl::StrCat("JSON payload cannot be parsed as valid JSON: ", err));
reader.getFormattedErrorMessages()));
suite_.ReportFailure(test, level, request, response); suite_.ReportFailure(test, level, request, response);
return; return;
} }

Loading…
Cancel
Save