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


Java JsonProcessingException類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.JsonProcessingException的典型用法代碼示例。如果您正苦於以下問題:Java JsonProcessingException類的具體用法?Java JsonProcessingException怎麽用?Java JsonProcessingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonProcessingException類屬於com.fasterxml.jackson.core包,在下文中一共展示了JsonProcessingException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertToString

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
/**
 * convert Object into String.
 * @param obj Object
 * @return String
 */
public static String convertToString(Object obj) {
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        return objectMapper.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        log.error("JsonProcessingException while converting Entity into string", e);
    }
    return null;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:ObjectMapperUtil.java

示例2: createAuthnRequest

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
private SamlRequestDto createAuthnRequest(String issuer, String relayState, String publicCert, String privateKey) throws JsonProcessingException {
    String id = AuthnRequestIdGenerator.generateRequestId();
    Optional<Boolean> forceAuthentication = Optional.of(false);
    Optional<Integer> assertionConsumerServiceIndex = Optional.of(1);
    Optional<URI> assertionConsumerServiceUrl = Optional.empty();
    String anAuthnRequest = authnRequestFactory.anAuthnRequest(
            id,
            issuer,
            forceAuthentication,
            assertionConsumerServiceUrl,
            assertionConsumerServiceIndex,
            publicCert,
            privateKey,
            Endpoints.SSO_REQUEST_ENDPOINT,
            Optional.empty());
    SamlRequestDto authnRequestWrapper = new SamlRequestDto(anAuthnRequest, relayState, "ipAddress");
    return authnRequestWrapper;
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:19,代碼來源:SamlMessageReceiverApiResourceTest.java

示例3: getAllEventType

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
/**
 * method to get all the events type 
 * @param id
 * @return
 * @throws JsonProcessingException
 */
@RabbitListener(queues = "#{getAllEventTypeQueue.name}")
public String getAllEventType(byte[] id){
	String res = "";
	List<EventType> eventsType = eventTypeRepository.findAll();
	ObjectMapper mapper = new ObjectMapper();
	Log
	.forContext("MemberName", "getAllEventType")
	.forContext("Service", appName)
	.information("RabbitMQ : getAllEventType");
	try {
		res = mapper.writeValueAsString(eventsType);
	} catch (JsonProcessingException e1) {
		Log
		.forContext("MemberName", "getAllEventType")
		.forContext("Service", appName)
		.error(e1,"JsonProcessingException");
	}
	return res;
}
 
開發者ID:TraineeSIIp,項目名稱:PepSIIrup-2017,代碼行數:26,代碼來源:EventController.java

示例4: build

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
public ApiGatewayResponse build() {
    String body = null;
    if (rawBody != null) {
        body = rawBody;
    } else if (objectBody != null) {
        try {
            body = objectMapper.writeValueAsString(objectBody);
        } catch (JsonProcessingException e) {
            LOG.error("failed to serialize object", e);
            throw new RuntimeException(e);
        }
    } else if (binaryBody != null) {
        body = new String(Base64.getEncoder().encode(binaryBody), StandardCharsets.UTF_8);
    }
    return new ApiGatewayResponse(statusCode, body, headers, base64Encoded);
}
 
開發者ID:lambdacult,項目名稱:spark-examples,代碼行數:17,代碼來源:ApiGatewayResponse.java

示例5: testReplicationControllerCreation

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Test
public void testReplicationControllerCreation() {
    ResourceFileCreator resourceFileCreator = new ResourceFileCreator(Pod.getPods(TestNodeStacks.getLampNodeStacks(log)));

    HashMap<String, String> result = null;
    try {
        result = resourceFileCreator.create();
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        fail();
    }

    String service = result.get(appServiceName);
    String deployment = result.get(appDeploymentName);
    Yaml yaml = new Yaml();
    serviceTest((Map) yaml.load(service));
    deploymentTest((Map) yaml.load(deployment));
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:19,代碼來源:ResourceFileCreatorTest.java

示例6: buildResponseEntity

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
private HttpEntity<MultiValueMap<String, String>> buildResponseEntity(
    Submission submission, HttpHeaders headers) {
  logger.debug("Building response entity");
  MultiValueMap<String, String> map = new LinkedMultiValueMap<>();

  try {
    map.add("test_output", new ObjectMapper().writeValueAsString(
        submission.getTestOutput()));
  } catch (JsonProcessingException ex) {
    logger.debug("POJO deserialization failed");
  }
  map.add("stdout", submission.getStdout());
  map.add("stderr", submission.getStderr());
  map.add("validations", submission.getValidations());
  map.add("vm_log", submission.getVmLog());
  map.add("token", submission.getId().toString());
  map.add("status", submission.getStatus().toString());
  map.add("exit_code", submission.getExitCode().toString());

  return new HttpEntity<>(map, headers);
}
 
開發者ID:tdd-pingis,項目名稱:tdd-pingpong,代碼行數:22,代碼來源:FakeSandboxRestService.java

示例7: additionalPropertiesWorkWithAllVisibility

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Test
public void additionalPropertiesWorkWithAllVisibility() throws ClassNotFoundException, SecurityException, NoSuchMethodException, JsonProcessingException, IOException {
    mapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false);
    mapper.configure(MapperFeature.AUTO_DETECT_SETTERS, false);
    mapper.setVisibility(mapper.getVisibilityChecker().with(Visibility.ANY));

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/additionalProperties/defaultAdditionalProperties.json", "com.example");

    Class<?> classWithAdditionalProperties = resultsClassLoader.loadClass("com.example.DefaultAdditionalProperties");
    String jsonWithAdditionalProperties = "{\"a\":1, \"b\":2};";
    Object instanceWithAdditionalProperties = mapper.readValue(jsonWithAdditionalProperties, classWithAdditionalProperties);

    JsonNode jsonNode = mapper.readTree(mapper.writeValueAsString(instanceWithAdditionalProperties));

    assertThat(jsonNode.path("a").asText(), is("1"));
    assertThat(jsonNode.path("b").asInt(), is(2));
    assertThat(jsonNode.has("additionalProperties"), is(false));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:AdditionalPropertiesIT.java

示例8: serialize

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Override
public void serialize(Text text, JsonGenerator jgen, SerializerProvider sp)
  throws IOException, JsonProcessingException {

  boolean isNanoPlot = NanoPlot.class.equals(text.getPlotType());
  jgen.writeStartObject();
  jgen.writeObjectField("type", text.getClass().getSimpleName());
  jgen.writeObjectField("x", isNanoPlot ? processLargeNumber(text.getX()) : text.getX());
  jgen.writeObjectField("y", text.getY());
  jgen.writeObjectField("show_pointer", text.getShowPointer());
  jgen.writeObjectField("text", text.getText());
  jgen.writeObjectField("pointer_angle", text.getPointerAngle());
  jgen.writeObjectField("color", text.getColor());
  jgen.writeObjectField("size", text.getSize());
  jgen.writeEndObject();
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:17,代碼來源:TextSerializer.java

示例9: _testFailOnWritingStringFromNullReader

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
private void _testFailOnWritingStringFromNullReader(JsonFactory f, boolean useReader) throws Exception{
    JsonGenerator gen;
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    if (useReader) {
        gen = f.createGenerator(ObjectWriteContext.empty(), new OutputStreamWriter(bout, "UTF-8"));
    } else {
        gen = f.createGenerator(ObjectWriteContext.empty(), bout, JsonEncoding.UTF8);
    }
    gen.writeStartObject();

    try {
        gen.writeFieldName("a");
        gen.writeString(null, -1);
        gen.flush();
        String json = bout.toString("UTF-8");
        fail("Should not have let "+gen.getClass().getName()+".writeString() ': output = "+json);
    } catch (JsonProcessingException e) {
        verifyException(e, "null reader");
    }
    gen.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:GeneratorFailFromReaderTest.java

示例10: deserialize

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Override
public OAuth2RefreshToken deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {

    String tokenValue = null;
    Long expiration = null;

    while (p.nextToken() != JsonToken.END_OBJECT) {
        String name = p.getCurrentName();
        p.nextToken();
        if (TOKEN_VALUE.equals(name)) {
            tokenValue = p.getText();
        } else if (EXPIRATION.equals(name)) {
            try {
                expiration = p.getLongValue();
            } catch (JsonParseException e) {
                expiration = Long.valueOf(p.getText());
            }
        }
    }

    if (expiration != null) {
        return new DefaultExpiringOAuth2RefreshToken(tokenValue, new Date(expiration));
    } else {
        return new DefaultOAuth2RefreshToken(tokenValue);
    }
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:27,代碼來源:OAuth2RefreshTokenJackson2SerializerDeserializer.java

示例11: testGenerate_Password_WithFieldAddonLeft

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Test
public void testGenerate_Password_WithFieldAddonLeft() throws JsonProcessingException {
	UiForm ui = UiFormSchemaGenerator.get().generate(PasswordForm3.class);
	
	String json = new ObjectMapper().writeValueAsString(ui);
	Assert.assertThat(json, hasJsonPath("$.schema.properties.password.title",equalTo("Password")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')]",hasSize(1)));
	Assert.assertThat(json, hasJsonPath("$.schema.properties.password.pattern", equalTo("[a-z]")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].description",hasItem("This is password")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].placeholder",hasItem("Please set you password")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].validationMessage",hasItem("this is a validation msg")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].type",hasItem("password")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].notitle",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].readonly",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].fieldAddonLeft",hasItem("@")));

}
 
開發者ID:JsonSchema-JavaUI,項目名稱:sf-java-ui,代碼行數:18,代碼來源:PasswordFormTest.java

示例12: serialize

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Override
public void serialize(SubFunction value, JsonGenerator gen, SerializerProvider serializers)
    throws IOException, JsonProcessingException {
    gen.writeStartObject();
    gen.writeFieldName("Fn::Sub");

    if (value.getVariableMap() == null) {
        gen.writeString(value.getStringTemplate());
    } else {
        gen.writeStartArray();
        gen.writeString(value.getStringTemplate());
        serializers.defaultSerializeValue(value.getVariableMap(), gen);
        gen.writeEndArray();
    }

    gen.writeEndObject();
}
 
開發者ID:salesforce,項目名稱:cf2pojo,代碼行數:18,代碼來源:SubFunction.java

示例13: serialize

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
@Override
public void serialize(BeakerCodeCell value,
    JsonGenerator jgen,
    SerializerProvider provider)
    throws IOException, JsonProcessingException {

  synchronized (value) {
    jgen.writeStartObject();
    jgen.writeStringField("type", "BeakerCodeCell");
    jgen.writeStringField("execution_count", value.executionCount);
    jgen.writeStringField("cell_type", value.cellType);
    jgen.writeFieldName("outputs");
    if (!getObjectSerializer().writeObject(value.outputs, jgen, true))
      jgen.writeString(value.outputs.toString());
    jgen.writeFieldName("metadata");
    if (!getObjectSerializer().writeObject(value.metadata, jgen, true))
      jgen.writeString(value.metadata.toString());
    jgen.writeStringField("source", value.source);
    jgen.writeEndObject();
  }
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:22,代碼來源:BeakerCodeCell.java

示例14: getAuthorisationUrl

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
private String getAuthorisationUrl(BrightspaceAppContext appContext, String forwardUrl, @Nullable String postfixKey)
{
	final ObjectMapper mapper = new ObjectMapper();
	final ObjectNode stateJson = mapper.createObjectNode();
	stateJson.put(BrightspaceConnectorConstants.STATE_KEY_FORWARD_URL, forwardUrl);
	if( postfixKey != null )
	{
		stateJson.put(BrightspaceConnectorConstants.STATE_KEY_POSTFIX_KEY, postfixKey);
	}

	URI uri;
	try
	{
		uri = appContext.createWebUrlForAuthentication(
			URI.create(institutionService.institutionalise(BrightspaceConnectorConstants.AUTH_URL)),
			encrypt(mapper.writeValueAsString(stateJson)));
	}
	catch( JsonProcessingException e )
	{
		throw Throwables.propagate(e);
	}
	return uri.toString();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:24,代碼來源:BrightspaceConnectorServiceImpl.java

示例15: loadConfig

import com.fasterxml.jackson.core.JsonProcessingException; //導入依賴的package包/類
public ConfigLoadResult loadConfig(FilterConfig filterConfig) throws JsonProcessingException, IOException {
	if (result == null) {
		result = new ConfigLoadResult();
		result.settingsFile = findConfigFile(filterConfig);

		if (result.settingsFile != null) {
			result.settings = loadConfigFromFile(result.settingsFile, filterId);
		}

		if (result.settings == null) {
			result.settingsFile = null;
			result.settings = readConfigFromFilter(filterConfig);
		}
	}

	return result;
}
 
開發者ID:akharchuk,項目名稱:rate-limiting,代碼行數:18,代碼來源:ConfigurationLoader.java


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