本文整理汇总了Java中com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector类的典型用法代码示例。如果您正苦于以下问题:Java JaxbAnnotationIntrospector类的具体用法?Java JaxbAnnotationIntrospector怎么用?Java JaxbAnnotationIntrospector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JaxbAnnotationIntrospector类属于com.fasterxml.jackson.module.jaxb包,在下文中一共展示了JaxbAnnotationIntrospector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: objectMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.registerModule(new Ocpp12JacksonModule());
mapper.registerModule(new Ocpp15JacksonModule());
mapper.setAnnotationIntrospector(
AnnotationIntrospector.pair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(mapper.getTypeFactory())
)
);
return mapper;
}
示例2: Jackson2Parser
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public Jackson2Parser(Settings settings, TypeProcessor typeProcessor, boolean useJaxbAnnotations) {
super(settings, typeProcessor);
if (settings.jackson2ModuleDiscovery) {
objectMapper.registerModules(ObjectMapper.findModules(settings.classLoader));
}
for (Class<? extends Module> moduleClass : settings.jackson2Modules) {
try {
objectMapper.registerModule(moduleClass.newInstance());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(String.format("Cannot instantiate Jackson2 module '%s'", moduleClass.getName()), e);
}
}
if (useJaxbAnnotations) {
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(objectMapper.getTypeFactory());
objectMapper.setAnnotationIntrospector(introspector);
}
}
示例3: createJsonFactory
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private JsonFactory createJsonFactory() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setAnnotationIntrospector(
new AnnotationIntrospectorPair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())));
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
objectMapper.setDateFormat(df);
return objectMapper.getFactory();
}
示例4: init
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@PostConstruct
public void init() {
objectMapper = new ObjectMapper()
.setAnnotationIntrospector(
new AnnotationIntrospectorPair(
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())
, new JacksonAnnotationIntrospector()
)
)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
示例5: defaultObjectMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public static ObjectMapper defaultObjectMapper() {
return new XmlMapper(new XmlFactory(new WstxInputFactory(), new WstxPrefixedOutputFactory()))
.enable(SerializationFeature.INDENT_OUTPUT)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.registerModule(new ParserModule())
.setAnnotationIntrospector(AnnotationIntrospector.pair(
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()),
new JacksonAnnotationIntrospector()));
}
示例6: testSerializeJSON
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Test
public void testSerializeJSON() throws IOException {
Person person = new Person();
person.setId(12345L);
person.setFirstName("Peter");
person.setLastName("Walser");
person.setGender(Gender.MALE);
person.setDateOfBirth(LocalDate.of(1975, 12, 20));
StringWriter buffer = new StringWriter();
ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(
AnnotationIntrospector.pair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(mapper.getTypeFactory())
)
);
mapper.writerWithDefaultPrettyPrinter().writeValue(buffer, person);
String jsonString = buffer.toString();
System.out.println(jsonString);
Assert.assertTrue(jsonString.contains("\"id\" : 12345"));
Assert.assertTrue(jsonString.contains("\"first_name\" : \"Peter\""));
Assert.assertTrue(jsonString.contains("\"last_name\" : \"Walser\""));
Assert.assertTrue(jsonString.contains("\"gender\" : \"MALE\""));
Assert.assertTrue(jsonString.contains("\"birth_date\" : \"1975-12-20\""));
}
示例7: getGraphForJson
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
* Returns the graph for json.
*
* @param <T> the generic type
* @param json the json
* @param graphClass the graph class
* @return the graph for json
* @throws Exception the exception
*/
public static <T> T getGraphForJson(String json, Class<T> graphClass)
throws Exception {
InputStream in =
new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector introspector =
new JaxbAnnotationIntrospector(mapper.getTypeFactory());
mapper.setAnnotationIntrospector(introspector);
return mapper.readValue(in, graphClass);
}
示例8: getJsonForGraph
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
/**
* Returns the json for graph.
*
* @param object the object
* @return the json for graph
* @throws Exception the exception
*/
public static String getJsonForGraph(Object object) throws Exception {
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector introspector =
new JaxbAnnotationIntrospector(mapper.getTypeFactory());
mapper.setAnnotationIntrospector(introspector);
return mapper.writeValueAsString(object);
}
示例9: Allure1Plugin
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public Allure1Plugin() {
final SimpleModule module = new XmlParserModule()
.addDeserializer(ru.yandex.qatools.allure.model.Status.class, new StatusDeserializer());
xmlMapper = new XmlMapper()
.configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true)
.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
.registerModule(module);
}
示例10: configureMessageConverters
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder = new Jackson2ObjectMapperBuilder()
.annotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
.indentOutput(true);
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
converters.add(new MappingJackson2XmlHttpMessageConverter(
jacksonObjectMapperBuilder
.createXmlMapper(true)
.build()));
}
示例11: addJaxbAnnotationIntrospector
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private void addJaxbAnnotationIntrospector(ObjectMapper objectMapper) {
JaxbAnnotationIntrospector jaxbAnnotationIntrospector = new JaxbAnnotationIntrospector(
objectMapper.getTypeFactory());
objectMapper.setAnnotationIntrospectors(
createPair(objectMapper.getSerializationConfig(),
jaxbAnnotationIntrospector),
createPair(objectMapper.getDeserializationConfig(),
jaxbAnnotationIntrospector));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JerseyAutoConfiguration.java
示例12: configureMapperForSerialization
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
private ObjectMapper configureMapperForSerialization(){
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.registerModule(createSerializerModule());
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
return mapper;
}
示例13: createMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public static ObjectMapper createMapper() {
return new ObjectMapper()
.configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true)
.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))
.setSerializationInclusion(NON_NULL)
.configure(INDENT_OUTPUT, Boolean.getBoolean(INDENT_OUTPUT_PROPERTY_NAME))
.registerModule(new SimpleModule()
.addDeserializer(Status.class, new StatusDeserializer())
.addDeserializer(Stage.class, new StageDeserializer())
);
}
示例14: createRESTClientProxy
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
@Override
protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) {
List providers = new ArrayList();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
JacksonJaxbJsonProvider jsonProvider
= new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
providers.add(jsonProvider);
T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true);
Client client = (Client) t;
client.header("User-Agent", getImplementationName() + "=" + getVersion());
return t;
}
示例15: ApiHttpClient
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; //导入依赖的package包/类
public ApiHttpClient(final String channelAccessToken) {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(timeoutInMillis)
.setConnectTimeout(timeoutInMillis)
.build();
CloseableHttpAsyncClient asyncClient = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(requestConfig)
.addInterceptorLast((HttpRequest httpRequest, HttpContext httpContext) -> {
httpRequest.addHeader("X-Line-ChannelToken", channelAccessToken);
httpRequest.addHeader("Content-Type", "application/json; charser=UTF-8");
httpRequest.removeHeaders("Accept");
httpRequest.addHeader("Accept", "application/json; charset=UTF-8");
})
.setMaxConnTotal(maxConnections)
.setMaxConnPerRoute(maxConnections)
.disableCookieManagement()
.build();
asyncRestTemplate = new AsyncRestTemplate(new HttpComponentsAsyncClientHttpRequestFactory(asyncClient));
asyncRestTemplate.setErrorHandler(new ApiResponseErrorHandler());
httpHeaders = new HttpHeaders();
httpHeaders.set("X-Line-ChannelToken", channelAccessToken);
httpHeaders.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
List<MediaType> list = new ArrayList<>();
list.add(new MediaType("application", "json", Charset.forName("UTF-8")));
httpHeaders.setAccept(list);
objectMapper = new ObjectMapper();
objectMapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}