當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonProcessingException.getMessage方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:limberest,項目名稱:limberest,代碼行數:17,代碼來源:ServiceApi.java

示例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());
    }

}
 
開發者ID:xm-online,項目名稱:xm-ms-timeline,代碼行數:18,代碼來源:KafkaService.java

示例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);
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:17,代碼來源:MinijaxJsonReader.java

示例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);
    }
}
 
開發者ID:aCoder2013,項目名稱:fastmq,代碼行數:8,代碼來源:JsonUtils.java

示例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;
}
 
開發者ID:tdsis,項目名稱:lambda-forest,代碼行數:19,代碼來源:JsonResponseBodySerializerStrategy.java

示例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();
}
 
開發者ID:kloiasoft,項目名稱:eventapis,代碼行數:19,代碼來源:CompositeRepositoryImpl.java

示例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);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:19,代碼來源:VerifiableSourceTask.java

示例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);
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:23,代碼來源:VerifiableSinkTask.java

示例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();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:17,代碼來源:VerifiableSinkTask.java

示例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;
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:11,代碼來源:TransactionalMessageCopier.java

示例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;
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:11,代碼來源:VerifiableProducer.java

示例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);
		}
	}
}
 
開發者ID:holon-platform,項目名稱:holon-json,代碼行數:13,代碼來源:JacksonJsonPropertyBoxProvider.java

示例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);
    }
}
 
開發者ID:iyzico,項目名稱:boot-mon,代碼行數:10,代碼來源:BootmonClientRedisRepository.java


注:本文中的com.fasterxml.jackson.core.JsonProcessingException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。