[contexthub] Use new jsoncpp API
Reader / StyledWriter are deprecated upstream
Bug: 170642246
Change-Id: Id48592c7ef47392910b771e0da4d1d306b3424d8
diff --git a/contexthubhal/system_comms.cpp b/contexthubhal/system_comms.cpp
index 87e5fee..3010699 100644
--- a/contexthubhal/system_comms.cpp
+++ b/contexthubhal/system_comms.cpp
@@ -1015,8 +1015,8 @@
}
// Write the JSON string to disk.
- Json::StyledWriter writer;
- std::string serializedSettings(writer.write(*appsObject));
+ Json::StreamWriterBuilder factory;
+ std::string serializedSettings(Json::writeString(factory, *appsObject));
size_t size = serializedSettings.size();
if ((err = saved_apps_file.write(serializedSettings.c_str(), size)) != (ssize_t)size) {
ALOGW("saved_apps file write failed %d (%s)",
@@ -1050,8 +1050,10 @@
std::string str(buf);
std::shared_ptr<Json::Value> in(new Json::Value);
- Json::Reader reader;
- bool valid = reader.parse(str, *in);
+ Json::CharReaderBuilder builder;
+ std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
+ bool valid = reader->parse(
+ str.data(), str.data() + str.size(), in.get(), /* errorMessage = */ nullptr);
free(buf);
if (valid && in->isObject()) {