Reputation: 545
Scenario : Given an array consisting of objects representing a students marks and role in various subjects, I want to filter and see if there are any subjects where a particular student failed.
var sampleArray = [
{
"studentName" : "ABC",
"studentsMarks" = [
{
"subject" : "maths",
"marks" : "50"
},
{
"subject" : "science",
"marks" : "30"
}
]
},
{
"studentName" : "XYZ",
"studentsMarks" = [
{
"subject" : "maths",
"marks" : "90"
},
{
"subject" : "science",
"marks" : "50"
}
]
}
]
To perform the operation I am doing this :
sizeOf((sampleArray.studentsMarks filter ($.marks < 45))) > 0
this shall return me if there are any students with marks less than 45 in any subject.
I want to know if there is any Dataweave method that can simplify this operation for me?
Thanks in Advance.
Upvotes: 2
Views: 155