Open anuradharajan opened 2 years ago
I only can see this being done by JsonPath, if you're using JsonPath, although Newtonsoft Json does not provide a "contains"/regex operator like other languages do (operator ~=). Maybe it's possible to do this with JmesPath instead of JsonPath, if that's an option.
Could you provide me with how that transform will look? JsonPath or JmesPath
With JsonPath, the closest that I can think of is using #ifgroup inside the loop, but this will create empty items when the item does not match:
{
"Array": {
"#loop($.Array)": {
"#ifgroup(#mathgreaterthanorequalto(#firstindexof(#currentvalueatpath($.Id),AAA),0))": {
"Value": "#currentvalue()"
}
}
}
}
I don't know enough of JmesPath to provide a solution.
It seems there's an operator for regex in Newtonsoft Json after all. https://www.newtonsoft.com/json/help/html/RegexQuery.htm
{ "Array" [ { "Id" : "123AAA"}, { "Id" : "123BBB"}, { "Id" : "123AAA"} ] }
I want to loop through the Array objects that contain Id value = "AAA".
loop(???)