Forum Discussion

Ajay_Chawda's avatar
Ajay_Chawda
Contributor
4 years ago

How to filter json document based on keys present in another object

Hello Experts.
i want to filter json object based on keys present in another object of same document.

I have one json object which hold key information.
As end result we should consider only those values which has key value matching with json object which hold key information.

group object holds key information.
i should only consider value matching with key values from group object.

Regards,
Ajay
input_doc.txt (1.2 KB)

2 Replies

  • Cele's avatar
    Cele
    New Contributor II

    Hi @Ajay_Chawda

    Try to use the following expression and let me know if this helps you

    $.entries().filter(item =>  $group.findIndex(x => x.name == item[0]) != -1 ).reduce((acc, cur) => acc.extend({[cur[0]]: cur[1]}),{})
    

    BR
    Kristijan