public static <T> T parse(String str,Class<T> value) throws POAException
{
try {
if(jsonGenerator == null)
{
jsonGenerator = objectMapper.getJsonFactory().createJsonGenerator(System.out, JsonEncoding.UTF8);
}
T result = objectMapper.readValue(str, value);
return result;
} catch (JsonParseException e) {
e.printStackTrace();
throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
} catch (JsonMappingException e) {
e.printStackTrace();
throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
} catch (IOException e) {
e.printStackTrace();
throw new POAException(POAException.ERROR_JSONPARSE_ERROR);
}
}
json数据转化成实体的方法
最新推荐文章于 2024-07-26 22:19:13 发布