use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class WikiDao method mapperJson.
public WikiResponseEntity mapperJson(boolean useCache) {
// TODO Auto-generated method stub
WikiJson wikiJson;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, Urls.WIKI_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
wikiJson = mObjectMapper.readValue(result, new TypeReference<WikiJson>() {
});
if (wikiJson == null) {
return null;
}
this.mWikiResponseEntity = wikiJson.getResponse();
return mWikiResponseEntity;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class BlogsDao method getMore.
public BlogsMoreResponse getMore(String more_url) {
BlogsMoreResponse response;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, more_url + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, true);
response = mObjectMapper.readValue(result, new TypeReference<BlogsMoreResponse>() {
});
return response;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class DetailDao method mapperJson.
public DetailResponseEntity mapperJson(boolean useCache) {
try {
String result = RequestCacheUtil.getRequestContent(mActivity, mUrl, Constants.WebSourceType.Json, Constants.DBContentType.Content_content, useCache);
Log.i("info", mUrl);
DetailJson detailJson = mObjectMapper.readValue(result, new TypeReference<DetailJson>() {
});
this.mDetailResponseEntity = detailJson.getResponse();
return this.mDetailResponseEntity;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.JsonParseException in project databus by linkedin.
the class TestDbusEventBufferMult method convertToPhysicalSourceConfig.
public PhysicalSourceConfig convertToPhysicalSourceConfig(String str) {
_mapper = new ObjectMapper();
InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(str));
PhysicalSourceConfig pConfig = null;
try {
pConfig = _mapper.readValue(isr, PhysicalSourceConfig.class);
} catch (JsonParseException e) {
fail("Failed parsing", e);
} catch (JsonMappingException e) {
fail("Failed parsing", e);
} catch (IOException e) {
fail("Failed parsing", e);
}
try {
isr.close();
} catch (IOException e) {
fail("Failed", e);
}
return pConfig;
}
use of org.codehaus.jackson.JsonParseException in project openhab1-addons by openhab.
the class OpenPathsBinding method getUserLocation.
@SuppressWarnings("unchecked")
private Location getUserLocation(String accessKey, String secretKey) {
// build the OAuth service using the access/secret keys
OAuthService service = new ServiceBuilder().provider(new OpenPathsApi()).apiKey(accessKey).apiSecret(secretKey).build();
// build the request
OAuthRequest request = new OAuthRequest(Verb.GET, "https://openpaths.cc/api/1");
service.signRequest(Token.empty(), request);
request.addQuerystringParameter("num_points", "1");
// send the request and check we got a successful response
Response response = request.send();
if (!response.isSuccessful()) {
logger.error("Failed to request the OpenPaths location, response code: " + response.getCode());
return null;
}
// parse the response to build our location object
Map<String, Object> locationData;
String toParse = "{}";
try {
ObjectMapper jsonReader = new ObjectMapper();
toParse = response.getBody();
toParse = toParse.substring(1, toParse.length() - 2);
locationData = jsonReader.readValue(toParse, Map.class);
} catch (JsonParseException e) {
logger.error("Error parsing JSON:\n" + toParse, e);
return null;
} catch (JsonMappingException e) {
logger.error("Error mapping JSON:\n" + toParse, e);
return null;
} catch (IOException e) {
logger.error("An I/O error occured while decoding JSON:\n" + response.getBody());
return null;
}
float latitude = Float.parseFloat(locationData.get("lat").toString());
float longitude = Float.parseFloat(locationData.get("lon").toString());
String device = locationData.get("device").toString();
return new Location(latitude, longitude, device);
}
Aggregations