Complex object as a queryparameter in in java rest application -


i need able query resource filter many parameters (all optionals)

my url specification :

get http://something/version/resource?f={"param1":"1","param2":"something else", "param3":"tomato" 

i tried 2 approaches:

  1. @xmlrootelement created class filter , annotated @xmlrootelement parameters not parsed class.
@xmlrootelement     myclassfilter{    string param1;    string param2;    ..........  } 
  1. @beanparam removed @xmlrootelement annotation , put @queryparam annotation every field in class , in resource method put @beanparam one.
myclassfilter{    @queryparam("param1")    string param1;    @queryparam("param2")    string param2;    ..........  }    

i null objects both methods. point me right direction? consume services don't have experience on server side.

i solved problem, in method receive filter string:

@queryparam(value = "f") string f 

and parse using objectmapper:

objectmapper mapper = new objectmapper(); entityfilter filter = mapper.readvalue(f, entityfilter.class); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -