I need to create a servlet that whenever we write infinity.json the product whose properties has country mexico all Products should appear in json array.
@rohankalrainfinity.json is an ootb implementation to get data at all level. To solve your use case, you can write a servlet which uses JCR SQL2 to perform the required search to fetch results in Json.