Update for jart/json.cpp change

This commit is contained in:
Peter Johnson
2026-03-29 15:38:18 -07:00
parent de3e211fdb
commit 9ca93fa190
120 changed files with 1240 additions and 1087 deletions

View File

@@ -94,8 +94,8 @@ void DsClient::ParseJson() {
WPI_DEBUG4(m_logger, "DsClient JSON: {}", m_json);
unsigned int ip = 0;
try {
ip = wpi::util::json::parse(m_json).at("robotIP").get<unsigned int>();
} catch (wpi::util::json::exception& e) {
ip = wpi::util::json::parse_or_throw(m_json).at("robotIP").get_int();
} catch (std::logic_error& e) {
WPI_INFO(m_logger, "DsClient JSON error: {}", e.what());
return;
}

View File

@@ -279,17 +279,17 @@ void MyHttpConnection::ProcessRequest() {
bool subdir = entry.is_directory(ec);
std::string name = entry.path().filename().string();
if (subdir) {
dirs.emplace_back(wpi::util::json{{"name", std::move(name)}});
dirs.emplace_back(wpi::util::json::object("name", std::move(name)));
} else {
files.emplace_back(
wpi::util::json{{"name", std::move(name)},
{"size", subdir ? 0 : entry.file_size(ec)}});
wpi::util::json::object("name", std::move(name), "size",
subdir ? 0 : entry.file_size(ec)));
}
}
SendResponse(200, "OK", "text/json",
wpi::util::json{{"dirs", std::move(dirs)},
{"files", std::move(files)}}
.dump());
wpi::util::json::object("dirs", std::move(dirs), "files",
std::move(files))
.to_string());
} else if (fs::exists(indexpath)) {
SendFileResponse(200, "OK", GetMimeType("html"), indexpath,
"Content-Disposition: filename=\"index.html\"\r\n");