cancel
Showing results for 
Search instead for 
Did you mean: 

Check array is empty or not

Gayathry
New Contributor II

Hi Experts,

I have a requirement where I need to check ‘group’ array is empty or not. Could someone help with the JSON path expression.

Empty group array JSON looks like:
[
{
“group”: [
{}
]
}
]
Non empty group array json loiks like:

[
{
“group”: [
{
“ID”: “002”
}
{
“ID”: “003”
}
]
}
]

Thanks in Advance.

7 REPLIES 7

Gayathry
New Contributor II

Thanks a lot Bojan. instead if using ‘ID’ in json path expression is there any other way to check list is empty as the object ‘ID’ name is a dynamic one.

Yes @Gayathry , try this:

$group.filter(x=>x.keys().length != 0).length > 0

Gayathry
New Contributor II

Thank you so much. It worked.