本文整理汇总了Java中com.fasterxml.jackson.core.JsonProcessingException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java JsonProcessingException.getMessage方法的具体用法?Java JsonProcessingException.getMessage怎么用?Java JsonProcessingException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonProcessingException
的用法示例。
在下文中一共展示了JsonProcessingException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeInternal
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override //Object就是springmvc返回值
protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException,
HttpMessageNotWritableException {
// 从threadLocal中获取当前的Request对象
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.currentRequestAttributes()).getRequest();
String callbackParam = request.getParameter(callbackName);
if (StringUtils.isEmpty(callbackParam)) {
// 没有找到callback参数,直接返回json数据
super.writeInternal(object, outputMessage);
} else {
JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
try {
//将对象转换为json串,然后用回调方法包括起来
String result = callbackParam + "(" + super.getObjectMapper().writeValueAsString(object)
+ ");";
IOUtils.write(result, outputMessage.getBody(), encoding.getJavaName());
} catch (JsonProcessingException ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
}
}
开发者ID:jthinking,项目名称:linux-memory-monitor,代码行数:25,代码来源:CallbackMappingJackson2HttpMessageConverter.java
示例2: getSwaggerJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public JSONObject getSwaggerJson(String path) throws ServiceApiException {
Swagger swagger = getSwagger(path);
try {
// Re-parse as JsonObject to ensure ordering of definitions and paths.
// TODO: make this optional (see limberest.yaml comments in limberest-demo)
JsonObject swaggerJson = new JsonObject(Json.mapper().writeValueAsString(swagger));
if (swaggerJson.has("definitions"))
swaggerJson.put("definitions", new JsonObject(swaggerJson.getJSONObject("definitions").toString()));
if (swaggerJson.has("paths"))
swaggerJson.put("paths", new JsonObject(swaggerJson.getJSONObject("paths").toString()));
return swaggerJson;
}
catch (JsonProcessingException ex) {
throw new ServiceApiException(ex.getMessage(), ex);
}
}
示例3: createSystemEvent
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private String createSystemEvent(String tenant, String command) {
SystemEvent event = new SystemEvent();
event.setEventId(MDCUtil.getRid());
event.setEventType(command);
event.setTenantInfo(TenantContext.getCurrent());
event.setMessageSource(appName);
event.getData().put(Constants.EVENT_TENANT, tenant);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
try {
return mapper.writeValueAsString(event);
} catch (JsonProcessingException e) {
log.error("System Event mapping error", e);
throw new BusinessException("Event mapping error", e.getMessage());
}
}
示例4: readFrom
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public Object readFrom(
final Class<Object> type,
final Type genericType,
final Annotation[] annotations,
final MediaType mediaType,
final MultivaluedMap<String, String> httpHeaders,
final InputStream entityStream)
throws IOException {
try {
return objectMapper.readValue(entityStream, type);
} catch (final JsonProcessingException ex) {
throw new BadRequestException(ex.getMessage(), ex);
}
}
示例5: toJson
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
public static String toJson(Object object) throws JsonException {
try {
return OBJECT_MAPPER.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new JsonException(e.getMessage(), e);
}
}
示例6: serialize
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public String serialize(Object entity) throws HttpException {
String json = null;
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
json = mapper.writeValueAsString(entity);
} catch (JsonProcessingException e) {
throw new InternalServerErrorException(e.getMessage(), e);
}
return json;
}
示例7: recordAndPublishInternal
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private <P extends PublishedEvent, T extends Exception> EventKey recordAndPublishInternal(
P publishedEvent, Optional<EventKey> previousEventKey, Function<EntityEvent, ConcurrencyResolver<T>> concurrencyResolverFactory
) throws EventStoreException, T {
EventKey eventKey = eventRecorder.recordEntityEvent(publishedEvent, previousEventKey, concurrencyResolverFactory);
publishedEvent.setSender(eventKey);
String event;
try {
event = objectMapper.writerWithView(Views.PublishedOnly.class).writeValueAsString(publishedEvent);
} catch (JsonProcessingException e) {
throw new EventStoreException(e.getMessage(), e);
}
PublishedEventWrapper publishedEventWrapper = new PublishedEventWrapper(operationContext.getContext(), event);
publishedEventWrapper.setUserContext(userContext.getUserContext());
operationRepository.publishEvent(publishedEvent.getClass().getSimpleName(), publishedEventWrapper);
checkOperationFinalStates(publishedEvent);
return publishedEvent.getSender();
}
示例8: commitRecord
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public void commitRecord(SourceRecord record) throws InterruptedException {
Map<String, Object> data = new HashMap<>();
data.put("name", name);
data.put("task", id);
data.put("topic", this.topic);
data.put("time_ms", System.currentTimeMillis());
data.put("seqno", record.value());
data.put("committed", true);
String dataJson;
try {
dataJson = JSON_SERDE.writeValueAsString(data);
} catch (JsonProcessingException e) {
dataJson = "Bad data can't be written as json: " + e.getMessage();
}
System.out.println(dataJson);
}
示例9: put
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public void put(Collection<SinkRecord> records) {
long nowMs = System.currentTimeMillis();
for (SinkRecord record : records) {
Map<String, Object> data = new HashMap<>();
data.put("name", name);
data.put("task", record.key()); // VerifiableSourceTask's input task (source partition)
data.put("sinkTask", id);
data.put("topic", record.topic());
data.put("time_ms", nowMs);
data.put("seqno", record.value());
data.put("offset", record.kafkaOffset());
String dataJson;
try {
dataJson = JSON_SERDE.writeValueAsString(data);
} catch (JsonProcessingException e) {
dataJson = "Bad data can't be written as json: " + e.getMessage();
}
System.out.println(dataJson);
unflushed.add(data);
}
}
示例10: flush
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public void flush(Map<TopicPartition, OffsetAndMetadata> offsets) {
long nowMs = System.currentTimeMillis();
for (Map<String, Object> data : unflushed) {
data.put("time_ms", nowMs);
data.put("flushed", true);
String dataJson;
try {
dataJson = JSON_SERDE.writeValueAsString(data);
} catch (JsonProcessingException e) {
dataJson = "Bad data can't be written as json: " + e.getMessage();
}
System.out.println(dataJson);
}
unflushed.clear();
}
示例11: toJsonString
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private static String toJsonString(Map<String, Object> data) {
String json;
try {
ObjectMapper mapper = new ObjectMapper();
json = mapper.writeValueAsString(data);
} catch (JsonProcessingException e) {
json = "Bad data can't be written as json: " + e.getMessage();
}
return json;
}
示例12: toJsonString
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
private String toJsonString(Map<String, Object> data) {
String json;
try {
ObjectMapper mapper = new ObjectMapper();
json = mapper.writeValueAsString(data);
} catch (JsonProcessingException e) {
json = "Bad data can't be written as json: " + e.getMessage();
}
return json;
}
示例13: writeInternal
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(outputMessage.getBody(), encoding);
try {
JavaType javaType = null;
if (jackson26Available && type != null && object != null && TypeUtils.isAssignable(type, object.getClass())) {
javaType = getJavaType(type, null);
}
ObjectWriter objectWriter;
objectWriter = this.objectMapper.writer();
if (javaType != null && javaType.isContainerType()) {
objectWriter = objectWriter.withType(javaType);
}
objectWriter.writeValue(generator, object);
generator.flush();
}
catch (JsonProcessingException ex) {
throw new HttpMessageNotWritableException("Could not write content: " + ex.getMessage(), ex);
}
}
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:28,代码来源:AbstractJackson2HttpMessageConverter.java
示例14: writeTo
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public void writeTo(PropertyBox t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
try (final Writer writer = new OutputStreamWriter(entityStream, CHARSET)) {
try {
getObjectWriter().writeValue(writer, t);
} catch (JsonProcessingException e) {
throw new WebApplicationException(e.getMessage(), e, Status.BAD_REQUEST);
}
}
}
示例15: save
import com.fasterxml.jackson.core.JsonProcessingException; //导入方法依赖的package包/类
@Override
public void save(BootmonClient bootmonClient) {
String key = String.format(KEY_PREFIX, bootmonClient.getName());
try {
redisTemplate.opsForValue().set(key, objectMapper.writeValueAsString(bootmonClient));
} catch (JsonProcessingException e) {
throw new BootmonRequestNotValidException(e.getMessage(), e);
}
}