mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
Added test_save_load for JSON
This commit is contained in:
@@ -10,7 +10,8 @@ namespace json {
|
||||
|
||||
template <class T>
|
||||
Result<T> load(const std::string& _fname) {
|
||||
return rfl::io::load_string(_fname).and_then(read<T>);
|
||||
const auto read_string = [](const auto& _str) { return read<T>(_str); };
|
||||
return rfl::io::load_string(_fname).and_then(read_string);
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace json {
|
||||
|
||||
template <class T>
|
||||
Result<Nothing> save(const std::string& _fname, const T& _obj) {
|
||||
return rfl::io::save_string(write(_obj));
|
||||
return rfl::io::save_string(_fname, write(_obj));
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
|
||||
Reference in New Issue
Block a user