Skip to content

Commit

Permalink
unexpected behavior for built-in function join of jmespath
Browse files Browse the repository at this point in the history
Unexpected behavior `join`,when elements are empty strings ahead of the json array. For example: `join(',', @)`
---
["", "", "a", "","b", "c", ""]
---
current result is: a,,b,c,
but expected: ,,a,,b,c,
  • Loading branch information
Uniplore-X authored Oct 25, 2024
1 parent 5967982 commit 1b54cae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/jsoncons_ext/jmespath/jmespath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,17 +1001,24 @@ namespace jmespath {

string_type sep = arg0.template as<string_type>();
string_type buf;
for (auto& j : arg1.array_range())
bool is_first = true;
for (auto &j : arg1.array_range())
{
if (!j.is_string())
{
ec = jmespath_errc::invalid_type;
return resources.null_value();
}
if (!buf.empty())

if (is_first)
{
is_first = false;
}
else
{
buf.append(sep);
}

auto sv = j.template as<string_view_type>();
buf.append(sv.begin(), sv.end());
}
Expand Down

0 comments on commit 1b54cae

Please sign in to comment.