java - RestTemplate getForEntity map to list of objects -
i have response url looks like:
{"seq":1,"id":"test1","changes":[{"rev":"1-52f5cdf008ecfbadf621c2939af7bd80"}]} {"seq":2,"id":"test2","changes":[{"rev":"1-8ce403a89dc5e7cb4187a16941b3fb7d"}]} {"seq":3,"id":"test3","changes":[{"rev":"1-52as7ddfd8ecfbadf621c2939af7bd80"}]} {"seq":4,"id":"test4","changes":[{"rev":"1-6yy03a89dc5e7cb45677a16941b3fb7d"}]}
if mapped object string, getting changes feed.
responseentity<string> responseentity = resttemplate.exchange(url, httpmethod.get, requestentity, string.class);
whereas, if happen use custom value object, somethings like:
public class knchanges { private long seq; private string id; private list changes;
with getter , setter methods, i'm getting first doc change details. if knchanges[] (array) used, first change obtained.
can please how json list structure mentioned above can mapped object?
thanks harsha
parameterizedtypereference<list<knchanges>> responsetype = new parameterizedtypereference<list<knchanges>>() {}; responseentity<list<knchanges>> resp = resttemplate.exchange(url, httpmethod.get, requestentity, responsetype); list<knchanges> list = resp.getbody();
Comments
Post a Comment