Reputation: 1463
In below JSON, I need get "fieldValue" only if "fieldName" contains 'mobile'.
{
"fields": [
{
"fieldName": "personal info",
"fieldValue": "something"
},
{
"fieldName": "private info",
"fieldValue": "nothing"
},
{
"fieldName": "mobile/personal number",
"fieldValue": "00000000000"
},
{
"fieldName": "official number",
"fieldValue": "1111111111111"
}
]
}
Note: Above Json is a sample one it doesn't contain actual values.
I also tried $.fields[?(@.fieldName =~ /mobile.*?/)].fieldValue
But it is returning whole list, Here mobile will come any place not only as prefix, I need to check if the fieldName contains 'mobile' then fieldValue should return.
Upvotes: 0
Views: 35