-1

Example:- searchCriteria(jsonObject)

1.

 jsonObject :   { employeeId :"xx" , 
              employeeName : "yy",  
             employeeDOB : "zz", 
              } 

2.

jsonObject :    { 
     SSN:"xx" 
}   

3.

jsonObject : { agentId:"xx",
                  agentType: "yy"   
}   

So basically, we want to build a custom search component(which can be reused for other search methods,only parameters will change) where we will pass jsonObject which may change according to point1,point2,point3.

thor
  • 21,418
  • 31
  • 87
  • 173
Bistu
  • 9
  • 1

1 Answers1

0

Jersey supports parsing values to Jettison JSONObject/JSONArray.

Example:

jsonObject :   { employeeId :"xx" , 
              employeeName : "yy",  
             employeeDOB : "zz", 
              } 

Code:

@POST
@Path("/rest")
@Consumes(MediaType.APPLICATION_JSON) 
public Object searchData(JSONObject json) {
  String empId = json.optString("employeeId");
  String empName = json.optString("employeeName");
  String empDOB = json.optString("employeeDOB");
  return new Object();
}

Similarly, you can implement your generic search to accept any object and extract the contents.

Kishore Bandi
  • 5,537
  • 2
  • 31
  • 52