Remove use of deprecated Json API

Bug: b/228975498
Change-Id: Ib8fafdd092669f1b430c1f02eeb522fe1b13b654
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258788
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36542}
This commit is contained in:
Björn Terelius 2022-04-13 15:39:23 +02:00 committed by WebRTC LUCI CQ
parent f22dfdddfe
commit e0ac10db0a
3 changed files with 15 additions and 6 deletions

View File

@ -318,9 +318,12 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
return;
}
Json::Reader reader;
Json::CharReaderBuilder factory;
std::unique_ptr<Json::CharReader> reader =
absl::WrapUnique(factory.newCharReader());
Json::Value jmessage;
if (!reader.parse(message, jmessage)) {
if (!reader->parse(message.data(), message.data() + message.length(),
&jmessage, nullptr)) {
RTC_LOG(LS_WARNING) << "Received unknown message. " << message;
return;
}

View File

@ -43,4 +43,5 @@ rtc_library("rtp_replayer") {
"../../../test:test_support",
"../../../test:video_test_common",
]
absl_deps = [ "//third_party/abseil-cpp/absl/memory:memory" ]
}

View File

@ -15,6 +15,7 @@
#include <string>
#include <utility>
#include "absl/memory/memory.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/transport/field_trial_based_config.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
@ -85,12 +86,16 @@ void RtpReplayer::Replay(
std::vector<VideoReceiveStream::Config> RtpReplayer::ReadConfigFromFile(
const std::string& replay_config,
Transport* transport) {
Json::Reader json_reader;
Json::CharReaderBuilder factory;
std::unique_ptr<Json::CharReader> json_reader =
absl::WrapUnique(factory.newCharReader());
Json::Value json_configs;
if (!json_reader.parse(replay_config, json_configs)) {
Json::String errors;
if (!json_reader->parse(replay_config.data(),
replay_config.data() + replay_config.length(),
&json_configs, &errors)) {
RTC_LOG(LS_ERROR)
<< "Error parsing JSON replay configuration for the fuzzer"
<< json_reader.getFormatedErrorMessages();
<< "Error parsing JSON replay configuration for the fuzzer: " << errors;
return {};
}