本文整理汇总了Java中com.fasterxml.jackson.core.JsonProcessingException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JsonProcessingException.printStackTrace方法的具体用法?Java JsonProcessingException.printStackTrace怎么用?Java JsonProcessingException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonProcessingException
的用法示例。
在下文中一共展示了JsonProcessingException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
protected String doInBackground(Void... params) {
ObjectMapper objectMapper = new ObjectMapper();
String listaIntereses="";
try {
listaIntereses = objectMapper.writeValueAsString(intereses);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
String resultado = null;
//Construyo el JSON
String interes = "{\"idUsuario\":\"" + idUsuario + "\",\"idsAreas\":"+listaIntereses+"}";
resultado = ConsultasBBDD.hacerConsulta(ConsultasBBDD.insertaOEliminaInteres, interes, "POST");
//resultado="";
return resultado;
}
示例2: manager
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@RequestMapping(value = "/detail", method = RequestMethod.GET, produces = "text/html;charset=utf8")
@ResponseBody
public String manager(@RequestParam("wid") long wid) {
WorkerInfo workerInfo = workerInfoService.queryDetailByWorkerId(wid);
WorkerProfile workerProfile = workerProfileService.queryDetailByWorkerId(wid);
WorkerDetail workerDetail;
if (workerProfile == null) {
workerProfileService.updateNewView(new WorkerProfile(wid, 1));
workerProfile = workerProfileService.queryDetailByWorkerId(wid);
}
workerDetail = new WorkerDetail(workerInfo, workerProfile);
ObjectMapper objectMapper = new ObjectMapper();
try {
return objectMapper.writeValueAsString(workerDetail);
} catch (JsonProcessingException e) {
e.printStackTrace();
return "0";
}
}
示例3: setPkg
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public void setPkg(Package pkg) {
this.pkg = pkg;
this.packageMetadataId = pkg.getMetadata().getId();
this.repositoryId = pkg.getMetadata().getRepositoryId();
ObjectMapper mapper = new ObjectMapper();
try {
// TODO verify this behavior
// Note that @JsonIgnore is on the package file byte array field.
this.pkgJsonString = mapper.writeValueAsString(pkg);
}
catch (JsonProcessingException e) {
e.printStackTrace();
}
}
示例4: objectToJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
/**
* 将对象转换成json字符串。
* <p>Title: pojoToJson</p>
* <p>Description: </p>
* @param data
* @return
*/
public static String objectToJson(Object data) {
try {
String string = MAPPER.writeValueAsString(data);
return string;
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
示例5: startAllProcessors
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private void startAllProcessors() throws MqttException {
int datagramCount = 0;
for (Map.Entry<Device, List<Processor>> entry : iProcessorMap.entrySet()) {
String mqttTopic = entry.getKey().getDeviceUUID();
ControlDatagram datagram = new ControlDatagram();
datagram.setAckTopic(sessionId);
datagram.setSessionId(sessionId);
datagram.setResourceId(entry.getKey().getDeviceUUID());
int sequence = 1;
for (Processor processor : entry.getValue()) {
ControlMethod method = new ControlMethod();
method.setMethodName("start_processor");
method.setSequenceId(sequence++);
Map<String, String> params = new HashMap<>();
params.put("proc_id", processor.getNifiId());
method.setParams(params);
datagram.addMethod(method);
}
String payloadJson = "";
try {
ObjectMapper objectMapper = new ObjectMapper();
payloadJson = objectMapper.writeValueAsString(datagram);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
System.out.println(payloadJson);
// publish to Mqtt
MqttMessage message = new MqttMessage(payloadJson.getBytes());
message.setQos(2);
mqttClient.publish(mqttTopic, message);
datagramCount++;
}
Map<Integer, ResponseDatagram> responses =
ControlResponseReceiver.receiveResponse(datagramCount, sessionId, mqttClient.getServerURI());
}
示例6: objectToJsonExclude
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public static String objectToJsonExclude(Object data,String filterName, String ...exName) {
try {
SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter
.serializeAllExcept(exName);
FilterProvider filters = new SimpleFilterProvider()
.addFilter(filterName, theFilter);
return MAPPER.writer(filters).writeValueAsString(data);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
示例7: save
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public void save(String key, Object object) {
ObjectWriter objectWriter = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
String jsonString = objectWriter.writeValueAsString(object);
preferences.edit().putString(key, jsonString).apply();
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
示例8: toJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
/**
* Helper method to convert a json object to a string.
*
* @param object object to convert to a string
* @return the string
*/
public static String toJson(final Object object) {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
String jsonRep = "";
try {
jsonRep = mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return jsonRep;
}
示例9: insert
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public long insert(List<String> columns, List<Object> args, int[] types) {
String insertColumns = primaryKeyName();
String insertPlaceholders = "nextval('"+tableName()+"_id_seq')";
for (String column : columns) {
insertColumns += "," + column;
insertPlaceholders += ",?";
}
insertColumns += ", " + createdAtName();
insertPlaceholders += ", now()";
insertColumns += ", " + updatedAtName();
insertPlaceholders += ", now()";
String sql = "insert into " + tableName() +
" ("+insertColumns+") values ("+insertPlaceholders+")";
KeyHolder keyHolder = new GeneratedKeyHolder();
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sql, types);
pscf.setReturnGeneratedKeys(true);
try {
logger.info("insert.sql: {}, args: {}", sql, jsonMapper.writeValueAsString(args));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
writeJdbcTemplate.update(pscf.newPreparedStatementCreator(args), keyHolder);
if (keyHolder.getKeyList() != null && !keyHolder.getKeyList().isEmpty()) {
return (long) keyHolder.getKeyList().get(0).get(primaryKeyName());
}
return -1;
}
示例10: sendRequest
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
/**
* Send a JSON formatted request to the server
*/
protected void sendRequest(Map<String, String> reqMap) {
ObjectMapper mapper = new ObjectMapper();
try {
String jsonRequest = mapper.writer().writeValueAsString(reqMap);
out.println(jsonRequest);
out.flush();
} catch (JsonProcessingException e1) {
e1.printStackTrace();
}
}
示例11: toJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public String toJson() {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
示例12: toJSON
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public String toJSON() {
try {
return JsonUtils.getObjectMapper().writeValueAsString(this);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return "{}";
}
示例13: getMessage
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private String getMessage(@RequestBody Object object) {
ObjectMapper mapper = new ObjectMapper();
String result = null;
try {
result = mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
System.out.print("request boy convert to json error");
e.printStackTrace();
}
return result;
}
示例14: objectToJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
protected static String objectToJson(Object obj) {
try {
return sMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
示例15: isValidConfig
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public static void isValidConfig(CSVConfig config){
List<String> typeArray = new ArrayList<String>();
config.VertexTypes.forEach(vertextype -> typeArray.add(vertextype.name));
for (EdgeTypeBean edgeType: config.EdgeTypes){
for (RelationBean relation: edgeType.relations) {
//validate left and right are in the vertex types
if(!typeArray.contains(relation.left)){
throw new RuntimeException("relationships: "
+ relation.left + " is not of vertex types: " + typeArray.toString());}
if(!typeArray.contains(relation.right))
throw new RuntimeException("relationships: "
+ relation.right + " is not of vertex types: " + typeArray.toString());
//validate supernode vertice number is less than the total
Iterator<VertexTypeBean> vTypes = config.VertexTypes.iterator();
while (vTypes.hasNext()){
VertexTypeBean type = vTypes.next();
if (relation.left.equals(type.name) &&
relation.supernode != null &&
relation.supernode.get("vertices") > type.row){
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValueAsString(relation);
throw new RuntimeException(
mapper.writeValueAsString(relation) +
"supernode.vertices is greater than " +
type.name + "'s row"
);
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}