use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.
the class BlogsDao method mapperJson.
public BlogsResponseEntity mapperJson(boolean useCache) {
BlogsJson blogsJson_;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, Urls.BLOGS_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
blogsJson_ = mObjectMapper.readValue(result, new TypeReference<BlogsJson>() {
});
if (blogsJson_ == null) {
return null;
}
_blogsResponse = blogsJson_.getResponse();
return _blogsResponse;
} 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 gravel by gravel-st.
the class StringExtensions method parseAsJSONValue.
public static Map<String, Object> parseAsJSONValue(String src) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode rootNode;
try {
rootNode = (ObjectNode) mapper.readValue(src, JsonNode.class);
} catch (JsonParseException e) {
throw new RuntimeException(e);
} catch (JsonMappingException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
HashMap<String, Object> map = new HashMap<String, Object>();
for (Iterator<Entry<String, JsonNode>> iter = rootNode.getFields(); iter.hasNext(); ) {
Entry<String, JsonNode> field = iter.next();
JsonNode value = field.getValue();
Object o = jsonNodeAsSimpleObject(value);
map.put(field.getKey(), o);
}
return map;
}
use of org.codehaus.jackson.JsonParseException in project wonderdog by infochimps-labs.
the class ElasticSearchStorage method putNext.
/**
Here we handle both the delimited record case and the json case.
*/
@SuppressWarnings("unchecked")
@Override
public void putNext(Tuple t) throws IOException {
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(ResourceSchema.class);
MapWritable record = new MapWritable();
String isJson = property.getProperty(ES_IS_JSON);
// Handle delimited records (ie. isJson == false)
if (isJson != null && isJson.equals("false")) {
String[] fieldNames = property.getProperty(PIG_ES_FIELD_NAMES).split(COMMA);
for (int i = 0; i < t.size(); i++) {
if (i < fieldNames.length) {
try {
record.put(new Text(fieldNames[i]), new Text(t.get(i).toString()));
} catch (NullPointerException e) {
//LOG.info("Increment null field counter.");
}
}
}
} else {
if (!t.isNull(0)) {
String jsonData = t.get(0).toString();
// parse json data and put into mapwritable record
try {
HashMap<String, Object> data = mapper.readValue(jsonData, HashMap.class);
record = (MapWritable) toWritable(data);
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
}
}
}
try {
writer.write(NullWritable.get(), record);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
use of org.codehaus.jackson.JsonParseException in project databus by linkedin.
the class ClusterCheckpointPersistenceProvider method getCheckpoint.
/**
* internal function that fetches contents from Helix property store
*
* @param key
* @return checkpoint or null
*/
private Checkpoint getCheckpoint(String key) {
ZNRecord zn = _propertyStore.get(key, null, AccessOption.PERSISTENT);
if (zn != null) {
String v = zn.getSimpleField(KEY_CHECKPOINT);
try {
Checkpoint cp;
cp = new Checkpoint(v);
return cp;
} catch (JsonParseException e) {
LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
} catch (JsonMappingException e) {
LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
} catch (IOException e) {
LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
}
} else {
LOG.error("No record for key = " + key);
}
return null;
}
use of org.codehaus.jackson.JsonParseException in project databus by linkedin.
the class PhysicalSourceConfigBuilder method build.
@Override
public PhysicalSourceStaticConfig[] build() throws InvalidConfigException {
ObjectMapper mapper = new ObjectMapper();
PhysicalSourceStaticConfig[] list = new PhysicalSourceStaticConfig[null == _fileNames ? 0 : _fileNames.length];
if (_fileNames == null)
return list;
for (int i = 0; i < _fileNames.length; ++i) {
File sourceJson = _fileNames[i];
PhysicalSourceConfig pConfig = null;
Exception e = null;
try {
pConfig = mapper.readValue(sourceJson, PhysicalSourceConfig.class);
} catch (JsonParseException jpe) {
e = jpe;
} catch (JsonMappingException jme) {
e = jme;
} catch (IOException ioe) {
e = ioe;
}
if (e != null || pConfig == null) {
throw new InvalidConfigException(e);
}
pConfig.checkForNulls();
LOG.info("Generated Physical source config: name= " + pConfig.getId());
list[i] = pConfig.build();
}
/*
for(PhysicalSourceStaticConfig pCfg : pConfigs) {
for(LogicalSourceStaticConfig lSC : pCfg.getSources()) {
config.setSourceName("" + lSC.getId(), lSC.getName());
}
}
*/
return list;
}
Aggregations