public class ResourceSearchUnmarshaller extends AbstractUnmarshaller<ResourceSearchResult> {
@Override
protected ResourceSearchResult parse(Object json) {
WSUtils utils = WSUtils.getINSTANCE();
ResourceSearchResult result = new ResourceSearchResult();
result.setPage(utils.getInteger(json, "page"));
result.setPageSize(utils.getInteger(json, "page_size"));
result.setTotal(utils.getInteger(json, "total"));
List<ResourceSearchResult.Resource> resources = new ArrayList<ResourceSearchResult.Resource>();
JSONArray dataJson = JsonUtils.getArray((JSONObject) json, "data");
if (dataJson != null) {
for (Object jsonResource : dataJson) {
ResourceSearchResult.Resource resource = new ResourceSearchResult.Resource();
resource.setKey(JsonUtils.getString((JSONObject) jsonResource, "key"));
resource.setName(JsonUtils.getString((JSONObject) jsonResource, "nm"));
resource.setQualifier(JsonUtils.getString((JSONObject) jsonResource, "q"));
resources.add(resource);
}
}
result.setResources(resources);
return result;
}