Skip to content

Commit

Permalink
fix compilation issue (#4613)
Browse files Browse the repository at this point in the history
* fix compilation issue

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* add unit test

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci failure check

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

---------

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
  • Loading branch information
hnampally authored Jan 22, 2025
1 parent 786c504 commit bf8ccc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/nlohmann/detail/json_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ class json_pointer
// iterate array and use index as reference string
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
{
flatten(detail::concat(reference_string, '/', std::to_string(i)),
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
value.m_data.m_value.array->operator[](i), result);
}
}
Expand All @@ -769,7 +769,7 @@ class json_pointer
// iterate object and use keys as reference string
for (const auto& element : *value.m_data.m_value.object)
{
flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result);
flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15239,7 +15239,7 @@ class json_pointer
// iterate array and use index as reference string
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
{
flatten(detail::concat(reference_string, '/', std::to_string(i)),
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
value.m_data.m_value.array->operator[](i), result);
}
}
Expand All @@ -15258,7 +15258,7 @@ class json_pointer
// iterate object and use keys as reference string
for (const auto& element : *value.m_data.m_value.object)
{
flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result);
flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result);
}
}
break;
Expand Down
8 changes: 8 additions & 0 deletions tests/src/unit-alt-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,12 @@ TEST_CASE("alternative string type")
alt_json const j2 = {"foo", "bam"};
CHECK(alt_json::diff(j1, j2).dump() == "[{\"op\":\"replace\",\"path\":\"/1\",\"value\":\"bam\"},{\"op\":\"remove\",\"path\":\"/2\"}]");
}

SECTION("flatten")
{
// a JSON value
const alt_json j = alt_json::parse(R"({"foo": ["bar", "baz"]})");
const auto j2 = j.flatten();
CHECK(j2.dump() == R"({"/foo/0":"bar","/foo/1":"baz"})");
}
}

0 comments on commit bf8ccc2

Please sign in to comment.