本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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();
}
示例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();
}
示例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);
}
}
示例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("@")));
}
示例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();
}
示例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();
}
}
示例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();
}
示例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;
}