add yyjson_read_flag symmetric to the yyjson_write_flag, so that non standard json's can be both written and read (#374)

This commit is contained in:
George Evmenov
2025-03-08 09:01:11 +08:00
committed by GitHub
parent ec8c19fa3e
commit 2ed458a194
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -9,9 +9,9 @@ namespace rfl {
namespace json { namespace json {
template <class T, class... Ps> template <class T, class... Ps>
Result<T> load(const std::string& _fname) { Result<T> load(const std::string& _fname, const yyjson_read_flag _flag = 0) {
const auto read_string = [](const auto& _str) { const auto read_string = [_flag](const auto& _str) {
return read<T, Ps...>(_str); return read<T, Ps...>(_str, _flag);
}; };
return rfl::io::load_string(_fname).and_then(read_string); return rfl::io::load_string(_fname).and_then(read_string);
} }
+2 -2
View File
@@ -31,8 +31,8 @@ auto read(const InputVarType& _obj) {
/// Parses an object from JSON using reflection. /// Parses an object from JSON using reflection.
template <class T, class... Ps> template <class T, class... Ps>
Result<internal::wrap_in_rfl_array_t<T>> read( Result<internal::wrap_in_rfl_array_t<T>> read(
std::string_view const _json_str) { std::string_view const _json_str, const yyjson_read_flag _flag = 0) {
yyjson_doc* doc = yyjson_read(_json_str.data(), _json_str.size(), 0); yyjson_doc* doc = yyjson_read(_json_str.data(), _json_str.size(), _flag);
if (!doc) { if (!doc) {
return error("Could not parse document"); return error("Could not parse document");
} }