本文整理汇总了Java中com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule类的典型用法代码示例。如果您正苦于以下问题:Java JaxbAnnotationModule类的具体用法?Java JaxbAnnotationModule怎么用?Java JaxbAnnotationModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JaxbAnnotationModule类属于com.fasterxml.jackson.module.jaxb包,在下文中一共展示了JaxbAnnotationModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JacksonMessageSerializer
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public JacksonMessageSerializer() {
this(new ObjectMapper());
objectMapper.registerModule(new JaxbAnnotationModule());
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.configure(
MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
}
示例2: NsObjectTransducer
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
/**
* Creates instance of transducer using given NetSuite client.
*
* @param clientService client to be used
*/
protected NsObjectTransducer(NetSuiteClientService<?> clientService) {
this.clientService = clientService;
try {
datatypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new ComponentException(e);
}
objectMapper = new ObjectMapper();
// Customize typing of JSON objects.
objectMapper.setDefaultTyping(new NsTypeResolverBuilder(clientService.getBasicMetaData()));
// Register JAXB annotation module to perform mapping of data model objects to/from JSON.
JaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule();
objectMapper.registerModule(jaxbAnnotationModule);
setMetaDataSource(clientService.getMetaDataSource());
}
示例3: main
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
initializeDB();
// Jackson Object Mapper
ObjectMapper mapper = new ObjectMapper();
// Adding the Jackson Module to process JAXB annotations
JaxbAnnotationModule module = new JaxbAnnotationModule();
// configure as necessary
mapper.registerModule(module);
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
String result = mapper.writeValueAsString(people);
System.out.println(result);
mapper.writeValue(new File("people.json"), people);
}
示例4: init
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
@Override
public void init(final ServletConfig config) throws ServletException {
super.init(config);
final BeanConfig beanConfig = loadConfig(new File("logs/swagger.properties"));
beanConfig.setVersion("v1");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setBasePath("/render-ws");
beanConfig.setResourcePackage("org.janelia.render.service");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);
// Needed to register these modules to get Swagger to use JAXB annotations
// (see https://github.com/swagger-api/swagger-core/issues/960 for explanation)
Json.mapper().registerModule(new JaxbAnnotationModule());
Yaml.mapper().registerModule(new JaxbAnnotationModule());
}
示例5: init
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public void init() {
SimpleModule module = getModule();
SimpleDateFormat df = new SimpleDateFormat(DateUtils.DATE_FORMAT);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
mapper = new ObjectMapper();
mapper.setDateFormat(df);
mapper.registerModule(module);
mapper.registerModule(new JaxbAnnotationModule());
mapper.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
if (escapeForwardSlashes) {
mapper.getFactory().setCharacterEscapes(new EscapeForwardSlash());
}
}
示例6: init
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
@PostConstruct
public void init() {
SimpleModule module = new SimpleModule();
module.setMixInAnnotation(Resource.class, ResourceMix.class);
module.setMixInAnnotation(SchemaCollection.class, SchemaCollectionMixin.class);
module.setMixInAnnotation(SchemaImpl.class, SchemaImplMixin.class);
SimpleDateFormat df = new SimpleDateFormat(DateUtils.DATE_FORMAT);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
mapper = new ObjectMapper();
mapper.setDateFormat(df);
mapper.registerModule(new JaxbAnnotationModule());
mapper.registerModule(module);
mapper.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
if ( escapeForwardSlashes ) {
mapper.getFactory().setCharacterEscapes(new EscapeForwardSlash());
}
}
示例7: getSingletons
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
@Override
/* Risolve il problema del Provider JSON non trovato alla prima richiesta.
* Vedi https://java.net/jira/browse/GLASSFISH-21141 */
public Set<Object> getSingletons() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JaxbAnnotationModule());
return ImmutableSet
.<Object> builder()
.add(new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS)).build();
}
示例8: objectMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
/**
* This {@link ObjectMapper} sets up Jackson for some common defaults. This
* utilizes Vert.x mapper to support their json objects in addition it will
* prevent <code>null</code> from being put into a resulting JSON.
*
* @return configured object mapper
*/
@Bean
public ObjectMapper objectMapper() {
return Json.mapper.copy()
.registerModule(new SwaggerModule())
.registerModule(new JaxbAnnotationModule())
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
示例9: MessageUtils
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public MessageUtils() {
xmlMapper = new ExtendedXmlMapper();
xmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
xmlMapper.setDateFormat(new ISO8601DateFormat());
xmlMapper.registerModule(new JaxbAnnotationModule());
xmlMapper.setSerializationInclusion(Include.NON_NULL);
}
示例10: Client
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
private Client(
final String host,
final feign.Client client,
final feign.Logger.Level logLevel,
final RequestInterceptor requestInterceptor,
final Retryer retryer,
final Request.Options options
) {
final MetacatJsonLocator metacatJsonLocator = new MetacatJsonLocator();
final ObjectMapper mapper = metacatJsonLocator
.getPrettyObjectMapper()
.copy()
.registerModule(new GuavaModule())
.registerModule(new JaxbAnnotationModule());
log.info("Connecting to {}", host);
this.host = host;
feignBuilder = Feign.builder()
.client(client)
.logger(new Slf4jLogger())
.logLevel(logLevel)
.contract(new JAXRSContract())
.encoder(new JacksonEncoder(mapper))
.decoder(new JacksonDecoder(mapper))
.errorDecoder(new MetacatErrorDecoder(metacatJsonLocator))
.requestInterceptor(requestInterceptor)
.retryer(retryer)
.options(options);
api = getApiClient(MetacatV1.class);
partitionApi = getApiClient(PartitionV1.class);
metadataApi = getApiClient(MetadataV1.class);
resolverApi = getApiClient(ResolverV1.class);
tagApi = getApiClient(TagV1.class);
}
示例11: toJSON
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
private <T> String toJSON(T entity) throws IOException {
StringWriter sw = new StringWriter();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JaxbAnnotationModule());
mapper.writeValue(sw, entity);
return sw.toString();
}
示例12: getContext
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public ObjectMapper getContext(final Class<?> type) {
final ObjectMapper retval = new ObjectMapper();
// if the incoming JSON contains properties not defined in the object model, ignore them
retval.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
// use the JAX-B annotations to map the fields in the Conversation Protocol to the object model
retval.registerModule(new JaxbAnnotationModule());
// don't write out properties that are null or empty
retval.setSerializationInclusion(NON_EMPTY);
return retval;
}
示例13: ClientStarter
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
@VisibleForTesting
ClientStarter(@NonNull JerseyClientBuilder jerseyClientBuilder, @NonNull ObjectMapper objectMapper) {
this.jerseyClientBuilder = jerseyClientBuilder;
this.objectMapper = objectMapper;
JaxbAnnotationModule module = new JaxbAnnotationModule();
objectMapper.registerModule(module);
this.clientConfig = createConfig();
}
示例14: accept
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
public void accept(ObjectMapper mapper) {
JaxbAnnotationModule module = new JaxbAnnotationModule();
// configure as necessary
inc.map(include->mapper.setSerializationInclusion(include));
mapper.registerModule(module);
PluginLoader.INSTANCE.plugins.get().stream()
.filter(m -> m.jacksonModules()!=null)
.flatMap(m -> m.jacksonModules().stream())
.forEach(m -> mapper.registerModule(m));
mapper.registerModule(new Jdk8Module());
}
示例15: afterPropertiesSet
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
// serializing to singleelement arrays is enabled by default but just in case they change this in the future...
mapper.configure(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED, false);
// Register the JAXB annotation module
JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule();
// Make sure that JAXB is the primary serializer (technically the default behavior but let's be explicit)
jaxbModule.setPriority(Priority.PRIMARY);
mapper.registerModule(new JaxbAnnotationModule());
mapper.setTypeFactory(TypeFactory.defaultInstance().withModifier(typeModifier));
}