Skip to content

Commit 1b9e223

Browse files
committed
fix: JSON::Impl::SettingLoad<>
1 parent 2081335 commit 1b9e223

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

include/REX/REX/JSON.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,9 @@ namespace REX::JSON
3030
{
3131
public:
3232
Setting(path_t a_path, T a_default) :
33-
TSetting<T, Store>(a_default)
34-
{
35-
if (a_path[0] != '/') {
36-
m_path = std::format("/{}"sv, a_path);
37-
} else {
38-
m_path = std::move(a_path);
39-
}
40-
}
33+
TSetting<T, Store>(a_default),
34+
m_path(a_path)
35+
{}
4136

4237
public:
4338
virtual void Load(void* a_data, bool a_isBase) override

src/REX/REX/JSON.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ namespace REX::JSON
1717
T& a_valueDefault)
1818
{
1919
const auto& json = *static_cast<glz::json_t*>(a_data);
20-
a_value = glz::get<T>(json, a_path).value_or(a_valueDefault);
20+
if (a_path[0] != '/') {
21+
const auto path = std::format("/{}sv", a_path);
22+
a_value = glz::get<T>(json, path).value_or(a_valueDefault);
23+
} else {
24+
a_value = glz::get<T>(json, a_path).value_or(a_valueDefault);
25+
}
2126
}
2227

2328
template void SettingLoad<bool>(void*, path_t, bool&, bool&);
@@ -38,7 +43,12 @@ namespace REX::JSON
3843
T& a_value)
3944
{
4045
auto& json = *static_cast<glz::json_t*>(a_data);
41-
glz::set(json, a_path, a_value);
46+
if (a_path[0] != '/') {
47+
const auto path = std::format("/{}"sv, a_path);
48+
glz::set(json, path, a_value);
49+
} else {
50+
glz::set(json, a_path, a_value);
51+
}
4252
}
4353

4454
template void SettingSave<bool>(void*, path_t, bool&);

0 commit comments

Comments
 (0)