How to check for the length property with JsonLogic
See original GitHub issueHi, Sorry for coming back with another question please. My bad.
Here is my use case.
I have a JSON obejct. I am using json-logic-fs to apply the query formatted as jsonlogic
against my object. So far it works with the text fields.
What I also want to do is filter out the items which dont have children items inside . For example please see the following json object
{
"name" : "Category of the post",
"posts": [ {"id" : 1 , "title" : "my first post"}]
},
{
"name" : "Another post category",
"posts": []
}
I have the current fields set up as such
const fields = [
{ name: 'name', label: 'Category Name' },
{
name: 'posts',
label: 'Has posts',
valueEditorType: 'checkbox',
},
];
What I would really like to do is to generate a query that will filter out categories which do not have any post, i.e categories which have posts field length is 0, will be filtered out.
The existing default operators wont help, I presume as I cannot use them to check for the length of an array.
Is there a way I can create a length
operator and use it to filter categories which have the posts length as 0.
Sorry for a lengthy question.
Thanks once again for your time and patience.
With Regards Gagan
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)
I don’t know about “very popular” but thank you for the kind words!
You are godsend… Thanks a lot … it worked perfectly. Thank you once again. Much much appreciated. This is the first time, I am seeing such kind of support from the author of a very popular component. thanks once again. ❤️