Skip to content

Commit

Permalink
Remove deprecated Json::Reader in favor of Json::CharReader
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676132312
  • Loading branch information
zhangskz authored and copybara-github committed Sep 18, 2024
1 parent 5da098b commit f84a208
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<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(
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;
}
Expand Down

0 comments on commit f84a208

Please sign in to comment.