当前位置: 首页>>代码示例>>Java>>正文


Java JsonMappingException类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonMappingException的典型用法代码示例。如果您正苦于以下问题:Java JsonMappingException类的具体用法?Java JsonMappingException怎么用?Java JsonMappingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonMappingException类属于com.fasterxml.jackson.databind包,在下文中一共展示了JsonMappingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEchoContract

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
public static Echo_sol_Echo getEchoContract()
		throws JsonParseException, JsonMappingException, IOException, CipherException {
	Web3j web3j = Web3j.build(new HttpService());
	logger.debug("[ETH-INFO] Connected to TestRPC");

	ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
	WalletFile walletFile = objectMapper
			.readValue(ContractHelper.class.getResourceAsStream("/accountKeystore.json"), WalletFile.class);
	Credentials credentials = Credentials.create(Wallet.decrypt(password, walletFile));
	logger.debug("[ETH-INFO] Credentials: " + credentials.getAddress());

	logger.debug("[ETH-INFO] Loading contract: " + contractAddress);
	ese = Echo_sol_Echo.load(contractAddress, web3j, credentials, GAS_PRICE, GAS_LIMIT);

	startObservable();
	
	return ese;
}
 
开发者ID:CDCgov,项目名称:blockchain-collab,代码行数:19,代码来源:ContractHelper.java

示例2: validate

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
/**
 * Validate logins yml.
 * @param loginsYml logins yml
 * @return true if valid
 */
@PostMapping(value = "/logins/validate", consumes = {TEXT_PLAIN_VALUE})
@ApiOperation(value = "Validate uaa login properties format", response = UaaValidationVM.class)
@ApiResponses(value = {
    @ApiResponse(code = 200, message = "Uaa validation result", response = UaaValidationVM.class),
    @ApiResponse(code = 500, message = "Internal server error")})
@SneakyThrows
@Timed
public UaaValidationVM validate(@RequestBody String loginsYml) {
    try {
        mapper.readValue(loginsYml, TenantLogins.class);
        return UaaValidationVM.builder().isValid(true).build();
    } catch (JsonParseException | JsonMappingException e) {
        return UaaValidationVM.builder().isValid(false).errorMessage(e.getLocalizedMessage()).build();
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:21,代码来源:TenantLoginsResource.java

示例3: load

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
/**
 * Loads and returns the AWS Java SDK internal configuration from the classpath.
 */
static InternalConfig load() throws JsonParseException, JsonMappingException, IOException {
    // First try loading via the class by using a relative path
    URL url = ClassLoaderHelper.getResource(DEFAULT_CONFIG_RESOURCE_RELATIVE_PATH, true, InternalConfig.class); // classesFirst=true
    if (url == null) { // Then try with the absolute path
        url = ClassLoaderHelper.getResource(DEFAULT_CONFIG_RESOURCE_ABSOLUTE_PATH, InternalConfig.class);
    }
    InternalConfigJsonHelper config = loadfrom(url);
    InternalConfigJsonHelper configOverride;
    URL overrideUrl = ClassLoaderHelper.getResource("/" + CONFIG_OVERRIDE_RESOURCE, InternalConfig.class);
    if (overrideUrl == null) { // Try without a leading "/"
        overrideUrl = ClassLoaderHelper.getResource(CONFIG_OVERRIDE_RESOURCE, InternalConfig.class);
    }
    if (overrideUrl == null) {
        log.debug("Configuration override " + CONFIG_OVERRIDE_RESOURCE + " not found.");
        configOverride = new InternalConfigJsonHelper();
    } else {
        configOverride = loadfrom(overrideUrl);
    }
    InternalConfig merged = new InternalConfig(config, configOverride);
    merged.setDefaultConfigFileLocation(url);
    merged.setOverrideConfigFileLocation(overrideUrl);
    return merged;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:InternalConfig.java

示例4: validate

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@PostMapping(value = "/timelines/properties/validate", consumes = {TEXT_PLAIN_VALUE})
@ApiOperation(value = "Validate timeline properties format", response = TimeLineValidationVM.class)
@ApiResponses(value = {
    @ApiResponse(code = 200, message = "Timeline validation result", response = TimeLineValidationVM.class),
    @ApiResponse(code = 500, message = "Internal server error")})
@SneakyThrows
@Timed
public TimeLineValidationVM validate(@RequestBody String timelineYml) {
    try {
        mapper.readValue(timelineYml, TenantProperties.class);
        return TimeLineValidationVM.builder().isValid(true).build();
    } catch (JsonParseException | JsonMappingException e) {
        log.error("Error while validation", e);
        return TimeLineValidationVM.builder().isValid(false).errorMessage(e.getLocalizedMessage()).build();
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:17,代码来源:TimelinePropertiesResource.java

示例5: getBadReportDetails

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@Test
void getBadReportDetails() throws NoSuchFieldException, IllegalAccessException, JsonProcessingException {
	ObjectMapper mockMapper = mock(ObjectMapper.class);
	when(mockMapper.writeValueAsBytes(any(AllErrors.class)))
		.thenThrow(new JsonMappingException("meep"));

	Converter converter = new Converter(
		new PathSource(Paths.get("../qrda-files/valid-QRDA-III-latest.xml")));
	Converter.ConversionReport badReport = converter.getReport();

	Field field = badReport.getClass().getDeclaredField("mapper");
	field.setAccessible(true);
	field.set(badReport, mockMapper);

	assertThrows(EncodeException.class, badReport::getValidationErrorsSource);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:17,代码来源:ConversionReportTest.java

示例6: testArray

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@Test
public void testArray() throws JsonParseException, JsonMappingException, IOException {
	assertTrue(config.getProperty("phoneNumbers", List.class) instanceof List);
	final List<Map<String, String>> testList = new ArrayList<>();

	Map<String, String> testMapEntry = new HashMap<>();
	testMapEntry.put("type", "home");
	testMapEntry.put("number", "212 555-1234");
	testList.add(testMapEntry);
	testMapEntry = new HashMap<>();
	testMapEntry.put("type", "office");
	testMapEntry.put("number", "646 555-4567");
	testList.add(testMapEntry);

	assertEquals(testList, config.getProperty("phoneNumbers", List.class));
	assertEquals(new ArrayList<>(), config.getProperty("children", List.class));
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:18,代码来源:ConfigTest.java

示例7: getSchemma

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
private static Optional<JsonSchema> getSchemma(Class<?> clazz) {
	ObjectMapper mapper = new ObjectMapper();
	Optional<JsonSchema> schema = Optional.empty();
	SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
	Optional<Class<?>> realClazz = ReflectionUtils.getGenericClass(clazz);
	boolean iterable = Iterable.class.isAssignableFrom(clazz) && realClazz.isPresent();
	if (iterable) {
		clazz = realClazz.get();
	}

	try {
		mapper.acceptJsonFormatVisitor(clazz, visitor);
		JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
		schema = Optional.ofNullable(schemaGen.generateSchema(clazz));
		if (iterable) {
			// TODO: decirle que es una collection
		}
	} catch (JsonMappingException e) {
		LOGGER.error("Se produjo un error al crear el JsonSchemma para la clase {}", clazz.getSimpleName(), e);
	}
	return schema;
}
 
开发者ID:damianwajser,项目名称:spring-rest-commons-options,代码行数:23,代码来源:JsonSchemmaUtils.java

示例8: getAPIKeyList

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
private List<String> getAPIKeyList() throws ServerError, JsonParseException, JsonMappingException, IOException{
  	List<String> list = new ArrayList<String>();
  	
String accountListUrlPath = props.getProperty("application-list-url-path");
    
accountListUrlPath=accountListUrlPath.replaceAll("<token>",  props.getProperty("acccess-token"));
accountListUrlPath=accountListUrlPath.replaceAll("<serviceid>", props.getProperty("service-id-a"));
    
//String body = props.getProperty("tempbody");
String body = apiAccessor.get(HOST+accountListUrlPath).getBody();
   while ( body.indexOf("user_key")!=-1){							
   	int indexOfStartOfKey = body.indexOf("user_key") + 11;
   	int indexOfEndOfKey = indexOfStartOfKey+32; 
   	String apiKey = body.substring(indexOfStartOfKey, indexOfEndOfKey);	   
   	list.add(apiKey);
   	
   	body = body.substring(indexOfEndOfKey);
   	
   }
  	
  	return list;
  }
 
开发者ID:tnscorcoran,项目名称:light-4-j-plugin-wrapper,代码行数:23,代码来源:UtilitiesServiceImpl.java

示例9: fromJsonNode

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
public static QueryObjectProvider fromJsonNode(CatalogService catalogService, VirtualObjectService virtualObjectService, PlatformServer server, JsonNode fullQuery, Integer rid, PackageMetaData packageMetaData) throws JsonParseException, JsonMappingException, IOException, QueryException {
	if (fullQuery instanceof ObjectNode) {
		JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(packageMetaData);
		Query query = converter.parseJson("query", (ObjectNode) fullQuery);
		return new QueryObjectProvider(catalogService, virtualObjectService, server, query, rid, packageMetaData);
	} else {
		throw new QueryException("Query root must be of type object");
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:10,代码来源:QueryObjectProvider.java

示例10: retrievePaymentCommandReceived

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@StreamListener(target = Sink.INPUT, 
    condition="payload.messageType.toString()=='FetchGoodsCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<FetchGoodsCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<FetchGoodsCommandPayload>>(){});
  
  FetchGoodsCommandPayload fetchGoodsCommand = message.getPayload();    
  String pickId = inventoryService.pickItems( // 
      fetchGoodsCommand.getItems(), fetchGoodsCommand.getReason(), fetchGoodsCommand.getRefId());
  
  messageSender.send( //
      new Message<GoodsFetchedEventPayload>( //
          "GoodsFetchedEvent", //
          message.getTraceId(), //
          new GoodsFetchedEventPayload() //
            .setRefId(fetchGoodsCommand.getRefId())
            .setPickId(pickId)));
}
 
开发者ID:flowing,项目名称:flowing-retail,代码行数:19,代码来源:MessageListener.java

示例11: setTestPolicy

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
public String setTestPolicy(final RestTemplate acs, final HttpHeaders headers, final String endpoint,
        final String policyFile) throws JsonParseException, JsonMappingException, IOException {

    PolicySet policySet = new ObjectMapper().readValue(new File(policyFile), PolicySet.class);
    String policyName = policySet.getName();
    acs.put(endpoint + ACS_POLICY_SET_API_PATH + policyName, new HttpEntity<>(policySet, headers));
    return policyName;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:9,代码来源:PolicyHelper.java

示例12: withWriter

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
/**
 * A callback so a JsonGenerator can be used inline but exception are handled here
 * @param outStream OutputStream
 * @param writer The writer interface
 * @throws IOException
 */
public void withWriter(OutputStream outStream, Writer writer) throws IOException
{
    try
    {
        JsonGenerator generator = objectMapper.getJsonFactory().createJsonGenerator(outStream, encoding);
        writer.writeContents(generator, objectMapper);
    }
    catch (JsonMappingException error)
    {
        logger.error("Failed to write Json output",error);
    } 
    catch (JsonGenerationException generror)
    {
        logger.error("Failed to write Json output",generror);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:JacksonHelper.java

示例13: assertForbidden

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
private void assertForbidden(final String path) throws IOException, ClientProtocolException, JsonParseException, JsonMappingException {
	final HttpDelete httpdelete = new HttpDelete(BASE_URI + RESOURCE + path);
	HttpResponse response = null;
	try {
		response = httpclient.execute(httpdelete);
		Assert.assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatusLine().getStatusCode());
		final String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
		final Map<?, ?> result = new ObjectMapperTrim().readValue(content, HashMap.class);
		Assert.assertEquals("security", result.get("code"));
		Assert.assertNull(result.get("cause"));
		Assert.assertNull(result.get("message"));
	} finally {
		if (response != null) {
			response.getEntity().getContent().close();
		}
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:18,代码来源:ExceptionMapperIT.java

示例14: asDocumentInternal

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@Override
public <T> Document asDocumentInternal(T object) {
    ObjectMapper objectMapper = getObjectMapper();
    try {
        JsonNode node = objectMapper.convertValue(object, JsonNode.class);
        return loadDocument(node);
    } catch (IllegalArgumentException iae) {
        log.error("Error while converting object to document ", iae);
        if (iae.getCause() instanceof JsonMappingException) {
            JsonMappingException jme = (JsonMappingException) iae.getCause();
            if (jme.getCause() instanceof StackOverflowError) {
                throw new ObjectMappingException(errorMessage(
                        "cyclic reference detected. " + jme.getPathReference(), OME_CYCLE_DETECTED));
            }
        }
        throw iae;
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:19,代码来源:JacksonMapper.java

示例15: retrievePaymentCommandReceived

import com.fasterxml.jackson.databind.JsonMappingException; //导入依赖的package包/类
@StreamListener(target = Sink.INPUT, 
    condition="payload.messageType.toString()=='RetrievePaymentCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<RetrievePaymentCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<RetrievePaymentCommandPayload>>(){});
  RetrievePaymentCommandPayload retrievePaymentCommand = message.getPayload();    
  
  System.out.println("Retrieve payment: " + retrievePaymentCommand.getAmount() + " for " + retrievePaymentCommand.getRefId());
  
  camunda.getRuntimeService().createMessageCorrelation(message.getMessageType()) //
    .processInstanceBusinessKey(message.getTraceId())
    .setVariable("amount", retrievePaymentCommand.getAmount()) //
    .setVariable("remainingAmount", retrievePaymentCommand.getAmount()) //
    .setVariable("refId", retrievePaymentCommand.getRefId()) //
    .correlateWithResult();    
}
 
开发者ID:flowing,项目名称:flowing-retail,代码行数:17,代码来源:MessageListener.java


注:本文中的com.fasterxml.jackson.databind.JsonMappingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。