Search code examples
javaandroidjsonparse-platformback4app

How to query on parse json object child value if it contains/equal to/greater than etc.?


I have a table in parse server (back4app) as below.

[{
  "companyName":"Abc Ltd",
  "branchAddress":"1-1,Xyz Street",
  "empInfo":
       {"name":"Naveen",
        "age":25,
        "salary":35000}
},
{
  "companyName":"Abc Ltd",
  "branchAddress":"123, Mno Street",
  "empInfo":
       {"name":"Some Other Person",
        "age":29,
        "salary":45000}
}
//Other Elements]

I want to get the elements who's salary is greater than certain amount !

empInfo is a JSONObject

I didnt find any query on JSONObject in official docs.

I hope I can find help here. Thank you.


Solution

  • You can try this code:

    ParseQuery<ParseObject> query = ParseQuery.getQuery("MyClass");
    query.whereGreaterThan("empInfo.salary", 1000);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> objs, ParseException e) {
        }
    });