How to add multiple Where conditions on array

"pricing": {
	"services": [{
	"service":"image-retouching",
	"price": [
	{
		"country": "us",
		"rate": "1.50"
	}],}]
}

Considering above JSON I am not able to put two ‘Where’ conditions i.e. Rate required for service = “image-retouching” and for country “us”.

I tried

json.data.pricing.services.where('service','image-retouching','==').values('price').where('country','us','==').values('rate')

Not sure if values formatter returns an array?
Try running it in parts to see which where clause is failing.

Also, please format code in your posts: How to format code in your posts

1 Like

Thanks for your response
If not values then what will return an array ?
Also will format code as per guidelines :+1:

Values actually returns an array of all items of entered property.
So, in your case, values('price') reutrns an array with first index having the actual price array.
The correct expression then is:
json.data.pricing.services.where('service','image-retouching','==').values('price')[0].where('country','us','==').values('rate')[0]

1 Like