Javascript Object to Java List -
i have following type of json want send java (i'm using jersey , default json parser comes with)
{ "something" : "1", "someotherthing" : "2" , ... }
but instead of creating object these properties in java, have single hashmap (or whatever) allow me still have access key , value
is such thing possible?
i don't have code transformation, use jersey this
@post @path("/purchase") @produces(mediatype.application_json) @consumes(mediatype.application_json) public statusresult purchase(userpurchaserequest upr) { }
if put properties , someotherthing strings in userpurchaserequest object, come in fine, want have in 1 structure (because don't know how many values get, , need names well)
yes, possible. still, depends on json java api using. example using jackson json can create hashmap json string this
objectmapper obj = new objectmapper(); string json = pbj.writevalue(<hashmap object>);
or vice-versa
hashmap obj = obj.readvalue(json, hashmap.class);
note - org.codehaus.jackson.map.objectmapper
Comments
Post a Comment