Skip to content

Commit bf8ccc2

Browse files
authored
fix compilation issue (#4613)
* fix compilation issue Signed-off-by: Harinath Nampally <[email protected]> * add unit test Signed-off-by: Harinath Nampally <[email protected]> * fix ci failure check Signed-off-by: Harinath Nampally <[email protected]> --------- Signed-off-by: Harinath Nampally <[email protected]>
1 parent 786c504 commit bf8ccc2

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

include/nlohmann/detail/json_pointer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ class json_pointer
750750
// iterate array and use index as reference string
751751
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
752752
{
753-
flatten(detail::concat(reference_string, '/', std::to_string(i)),
753+
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
754754
value.m_data.m_value.array->operator[](i), result);
755755
}
756756
}
@@ -769,7 +769,7 @@ class json_pointer
769769
// iterate object and use keys as reference string
770770
for (const auto& element : *value.m_data.m_value.object)
771771
{
772-
flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result);
772+
flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result);
773773
}
774774
}
775775
break;

single_include/nlohmann/json.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15239,7 +15239,7 @@ class json_pointer
1523915239
// iterate array and use index as reference string
1524015240
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
1524115241
{
15242-
flatten(detail::concat(reference_string, '/', std::to_string(i)),
15242+
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
1524315243
value.m_data.m_value.array->operator[](i), result);
1524415244
}
1524515245
}
@@ -15258,7 +15258,7 @@ class json_pointer
1525815258
// iterate object and use keys as reference string
1525915259
for (const auto& element : *value.m_data.m_value.object)
1526015260
{
15261-
flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result);
15261+
flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result);
1526215262
}
1526315263
}
1526415264
break;

tests/src/unit-alt-string.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,12 @@ TEST_CASE("alternative string type")
359359
alt_json const j2 = {"foo", "bam"};
360360
CHECK(alt_json::diff(j1, j2).dump() == "[{\"op\":\"replace\",\"path\":\"/1\",\"value\":\"bam\"},{\"op\":\"remove\",\"path\":\"/2\"}]");
361361
}
362+
363+
SECTION("flatten")
364+
{
365+
// a JSON value
366+
const alt_json j = alt_json::parse(R"({"foo": ["bar", "baz"]})");
367+
const auto j2 = j.flatten();
368+
CHECK(j2.dump() == R"({"/foo/0":"bar","/foo/1":"baz"})");
369+
}
362370
}

0 commit comments

Comments
 (0)