[sysid] Update JSON library usage (#5765)

This commit is contained in:
Tyler Veness
2023-10-14 23:52:50 -07:00
committed by GitHub
parent 638f04f626
commit 1f6492e3d8
3 changed files with 15 additions and 15 deletions

View File

@@ -12,9 +12,9 @@
#include <fmt/format.h>
#include <units/angle.h>
#include <units/math.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/StringExtras.h>
#include <wpi/StringMap.h>
#include <wpi/raw_istream.h>
#include "sysid/Util.h"
#include "sysid/analysis/FilteringUtils.h"
@@ -451,13 +451,13 @@ AnalysisManager::AnalysisManager(std::string_view path, Settings& settings,
{
// Read JSON from the specified path
std::error_code ec;
wpi::raw_fd_istream is{path, ec};
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(path, ec);
if (fileBuffer == nullptr || ec) {
throw FileReadingError(path);
}
is >> m_json;
m_json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
WPI_INFO(m_logger, "Read {}", path);
}
@@ -469,13 +469,13 @@ AnalysisManager::AnalysisManager(std::string_view path, Settings& settings,
// Read JSON from the specified path
std::error_code ec;
wpi::raw_fd_istream is{newPath, ec};
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(path, ec);
if (fileBuffer == nullptr || ec) {
throw FileReadingError(newPath);
}
is >> m_json;
m_json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
WPI_INFO(m_logger, "Read {}", newPath);
}