Filtering by child arrays
Using below as an example
[
{
"Name": "John Smith",
"Attributes": [
{
"Type": "Age",
"Value": 30
},
{
"Type": "Height",
"Value": 170
}
],
},
{
"Name": "Anne Smith",
"Attributes": [
{
"Type": "Age",
"Value": 33
},
{
"Type": "Height",
"Value": 167
}
],
},
]
I'm looking for a way to filter an array by child objects. For example, I want to find the person that is aged 30.
I want to be able to filter on Attributes.Type == "Age" and Attributes.Value == 30, and I need it to return the full object
{
"Name": "John Smith",
"Attributes": [
{
"Type": "Age",
"Value": 30
},
{
"Type": "Height",
"Value": 170
}
],
}
Hope that makes sense. Thanks
I think this is what you are looking for.
#(Attributes.#(Type=="Age"))#|#(Attributes.#(Value==30))#
The #(Attributes.#(Type=="Age"))# returns the objects that have an Attributes member with Type == "Age"
The | allows for doing another filter, which in this cast works like and operation.
The #(Attributes.#(Value==30))# returns the full objects that have an Attributes member with Value == 30
Yo can I get a certain amout of outputs starting from a certain cursor using gjson ?
Hi @amirhaouala
I would like to help but I'll need more information about what you are trying to achieve.
Is your question related to this issue? If not, it would be helpful to open a new issue and describe your question in detail.
Using below as an example
[ { "Name": "John Smith", "Attributes": [ { "Type": "Age", "Value": 30 }, { "Type": "Height", "Value": 170 } ], }, { "Name": "Anne Smith", "Attributes": [ { "Type": "Age", "Value": 33 }, { "Type": "Height", "Value": 167 } ], }, ]I'm looking for a way to filter an array by child objects. For example, I want to find the person that is aged 30.
I want to be able to filter on Attributes.Type == "Age" and Attributes.Value == 30, and I need it to return the full object
{ "Name": "John Smith", "Attributes": [ { "Type": "Age", "Value": 30 }, { "Type": "Height", "Value": 170 } ], }Hope that makes sense. Thanks
Is it possible to filter above object by Type where Type can be "Age" or "Height"