mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 11:05:08 -05:00
update json to 3.0.1
Some checks are pending
Build Binaries / Build Windows (push) Waiting to run
Build Binaries / Build macOS (push) Waiting to run
Build Binaries / Build Android (64-bit) (push) Waiting to run
Build Binaries / Build Android (32-bit) (push) Waiting to run
Build Binaries / Publish (push) Blocked by required conditions
Some checks are pending
Build Binaries / Build Windows (push) Waiting to run
Build Binaries / Build macOS (push) Waiting to run
Build Binaries / Build Android (64-bit) (push) Waiting to run
Build Binaries / Build Android (32-bit) (push) Waiting to run
Build Binaries / Publish (push) Blocked by required conditions
This commit is contained in:
parent
a3beed16f5
commit
4ba8751c68
7 changed files with 9 additions and 23 deletions
|
@ -241,8 +241,8 @@ if (ANDROID)
|
|||
endif()
|
||||
|
||||
set(MAT_JSON_AS_INTERFACE ON)
|
||||
CPMAddPackage("gh:geode-sdk/result@1.1.0")
|
||||
CPMAddPackage("gh:geode-sdk/json#8c6c325")
|
||||
CPMAddPackage("gh:geode-sdk/result@1.1.1")
|
||||
CPMAddPackage("gh:geode-sdk/json@3.0.1")
|
||||
CPMAddPackage("gh:fmtlib/fmt#11.0.2")
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE MAT_JSON_DYNAMIC=1)
|
||||
|
|
|
@ -41,8 +41,7 @@ namespace geode::utils::file {
|
|||
|
||||
template <class T>
|
||||
Result<> writeToJson(std::filesystem::path const& path, T const& data) {
|
||||
GEODE_UNWRAP_INTO(auto str, matjson::Value(data).dump());
|
||||
GEODE_UNWRAP(writeString(path, str));
|
||||
GEODE_UNWRAP(writeString(path, matjson::Value(data).dump()));
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -215,15 +215,11 @@ Result<> Mod::Impl::saveData() {
|
|||
// saveData is expected to be synchronous, and always called from GD thread
|
||||
ModStateEvent(m_self, ModEventType::DataSaved).post();
|
||||
|
||||
auto res = json.dump().andThen([&](auto const& str) {
|
||||
return utils::file::writeString(m_saveDirPath / "settings.json", str);
|
||||
});
|
||||
auto res = utils::file::writeString(m_saveDirPath / "settings.json", json.dump());
|
||||
if (!res) {
|
||||
log::error("Unable to save settings: {}", res.unwrapErr());
|
||||
}
|
||||
auto res2 = m_saved.dump().andThen([&](auto const& str) {
|
||||
return utils::file::writeString(m_saveDirPath / "saved.json", str);
|
||||
});
|
||||
auto res2 = utils::file::writeString(m_saveDirPath / "saved.json", m_saved.dump());
|
||||
if (!res2) {
|
||||
log::error("Unable to save values: {}", res2.unwrapErr());
|
||||
}
|
||||
|
|
|
@ -98,11 +98,7 @@ CFDataRef msgPortCallback(CFMessagePortRef port, SInt32 messageID, CFDataRef dat
|
|||
|
||||
std::string cdata(reinterpret_cast<char const*>(CFDataGetBytePtr(data)), CFDataGetLength(data));
|
||||
|
||||
auto res = geode::ipc::processRaw(port, cdata).dump();
|
||||
if (!res) {
|
||||
log::warn("Failed to process IPC message: {}", res.unwrapErr());
|
||||
}
|
||||
std::string reply = res.unwrapOr("");
|
||||
std::string reply = geode::ipc::processRaw(port, cdata).dump();
|
||||
|
||||
return CFDataCreate(NULL, (UInt8 const*)reply.data(), reply.size());
|
||||
}
|
||||
|
|
|
@ -21,11 +21,7 @@ void ipcPipeThread(HANDLE pipe) {
|
|||
if (ReadFile(pipe, buffer, sizeof(buffer) - 1, &read, nullptr)) {
|
||||
buffer[read] = '\0';
|
||||
|
||||
auto res = ipc::processRaw((void*)pipe, buffer).dump();
|
||||
if (!res) {
|
||||
log::warn("Failed to process IPC message: {}", res.unwrapErr());
|
||||
}
|
||||
std::string reply = res.unwrapOr("");
|
||||
std::string reply = ipc::processRaw((void*)pipe, buffer).dump();
|
||||
|
||||
DWORD written;
|
||||
WriteFile(pipe, reply.c_str(), reply.size(), &written, nullptr);
|
||||
|
|
|
@ -176,7 +176,7 @@ static Result<matjson::Value, ServerError> parseServerPayload(web::WebResponse c
|
|||
return Err(ServerError(response.code(), "Expected object, got {}", jsonTypeToString(json.type())));
|
||||
}
|
||||
if (!json.contains("payload")) {
|
||||
return Err(ServerError(response.code(), "Object does not contain \"payload\" key - got {}", json.dump().unwrapOr("?")));
|
||||
return Err(ServerError(response.code(), "Object does not contain \"payload\" key - got {}", json.dump()));
|
||||
}
|
||||
return Ok(json["payload"]);
|
||||
}
|
||||
|
|
|
@ -592,8 +592,7 @@ WebRequest& WebRequest::bodyString(std::string_view str) {
|
|||
}
|
||||
WebRequest& WebRequest::bodyJSON(matjson::Value const& json) {
|
||||
this->header("Content-Type", "application/json");
|
||||
// TODO: mat
|
||||
std::string str = json.dump(matjson::NO_INDENTATION).unwrapOr("");
|
||||
std::string str = json.dump(matjson::NO_INDENTATION);
|
||||
m_impl->m_body = ByteVector { str.begin(), str.end() };
|
||||
return *this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue