List of usage examples for com.fasterxml.jackson.module.jaxb JaxbAnnotationIntrospector JaxbAnnotationIntrospector
public JaxbAnnotationIntrospector(TypeFactory typeFactory)
From source file:com.infinities.nova.util.jackson.ObjectMapperResolver.java
public ObjectMapperResolver() { objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); objectMapper = objectMapper//from w w w . jav a 2 s . c o m .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper = objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.registerModule(new Hibernate4Module()); }
From source file:com.infinities.keystone4j.utils.jackson.ObjectMapperResolver.java
public ObjectMapperResolver() { objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); objectMapper = objectMapper//from w ww . j a va2 s .c om .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.registerModule(new Hibernate4Module()); }
From source file:com.ning.billing.recurly.model.RecurlyObject.java
public static XmlMapper newXmlMapper() { final XmlMapper xmlMapper = new XmlMapper(); xmlMapper.setSerializerProvider(new RecurlyXmlSerializerProvider()); final AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); final AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary); xmlMapper.setAnnotationIntrospector(pair); xmlMapper.registerModule(new JodaModule()); xmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); final SimpleModule m = new SimpleModule("module", new Version(1, 0, 0, null, null, null)); m.addSerializer(Accounts.class, new RecurlyObjectsSerializer<Accounts, Account>(Accounts.class, "account")); m.addSerializer(AddOns.class, new RecurlyObjectsSerializer<AddOns, AddOn>(AddOns.class, "add_on")); m.addSerializer(Adjustments.class, new RecurlyObjectsSerializer<Adjustments, Adjustment>(Adjustments.class, "adjustment")); m.addSerializer(Coupons.class, new RecurlyObjectsSerializer<Coupons, Coupon>(Coupons.class, "coupon")); m.addSerializer(Invoices.class, new RecurlyObjectsSerializer<Invoices, Invoice>(Invoices.class, "invoice")); m.addSerializer(Plans.class, new RecurlyObjectsSerializer<Plans, Plan>(Plans.class, "plan")); m.addSerializer(RecurlyErrors.class, new RecurlyObjectsSerializer<RecurlyErrors, RecurlyError>(RecurlyErrors.class, "error")); m.addSerializer(SubscriptionAddOns.class, new RecurlyObjectsSerializer<SubscriptionAddOns, SubscriptionAddOn>(SubscriptionAddOns.class, "subscription_add_on")); m.addSerializer(Subscriptions.class, new RecurlyObjectsSerializer<Subscriptions, Subscription>(Subscriptions.class, "subscription")); m.addSerializer(Transactions.class, new RecurlyObjectsSerializer<Transactions, Transaction>(Transactions.class, "transaction")); xmlMapper.registerModule(m);/*from w w w . j ava2 s . c om*/ return xmlMapper; }
From source file:com.abiquo.bond.api.AbiquoObjectMapper.java
private AbiquoObjectMapper() { objectMapper = new ObjectMapper().setAnnotationIntrospector( // new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))) // .registerModule(new AbiquoModule()); }
From source file:com.grl.tables.RowObjectSerializer.java
public RowObjectSerializer() { mapper = new ObjectMapper(); mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector(mapper.getTypeFactory()))); }
From source file:com.dell.asm.asmcore.asmmanager.util.deployment.HostnameUtilTest.java
static Deployment loadEsxiDeployment() throws IOException { // Set up some mock component data // Get some deployment data URL uri = HostnameUtilTest.class.getClassLoader().getResource("esxi_deployment.json"); assertNotNull("Failed to load esxi_deployment.json", uri); String json = IOUtils.toString(uri, Charsets.UTF_8); ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(ai); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper.readValue(json, Deployment.class); }
From source file:org.apache.streams.data.MoreoverJsonActivitySerializer.java
@Override public Activity deserialize(String serialized) { serialized = serialized.replaceAll("\\[[ ]*\\]", "null"); System.out.println(serialized); ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(introspector); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE); mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, Boolean.FALSE); mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE); mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE); mapper.configure(DeserializationFeature.WRAP_EXCEPTIONS, Boolean.TRUE); Article article;/*from w w w . ja v a 2s . c o m*/ try { ObjectNode node = (ObjectNode) mapper.readTree(serialized); node.remove("tags"); node.remove("locations"); node.remove("companies"); node.remove("topics"); node.remove("media"); node.remove("outboundUrls"); ObjectNode jsonNodes = (ObjectNode) node.get("source").get("feed"); jsonNodes.remove("editorialTopics"); jsonNodes.remove("tags"); jsonNodes.remove("autoTopics"); article = mapper.convertValue(node, Article.class); } catch (IOException e) { throw new IllegalArgumentException("Unable to deserialize", e); } return MoreoverUtils.convert(article); }
From source file:ru.anr.base.services.serializer.AbstractSerializerImpl.java
/** * Constructor. Here is performed general initialization for JSON and XML * configuration.//from ww w . j av a 2s . co m * * @param origin * Original mapper */ public AbstractSerializerImpl(ObjectMapper origin) { super(); this.objectMapper = origin; objectMapper.registerModule(new JSR310Module()); // ISO for date/time objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); objectMapper.setSerializationInclusion(Include.NON_NULL); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(objectMapper.getTypeFactory()); objectMapper.setAnnotationIntrospector(introspector); }
From source file:org.apache.streams.moreover.MoreoverJsonActivitySerializer.java
@Override public Activity deserialize(String serialized) { serialized = serialized.replaceAll("\\[[ ]*\\]", "null"); LOGGER.debug(serialized);//from w ww .j a v a 2 s.co m ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(introspector); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE); mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, Boolean.FALSE); mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE); mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE); mapper.configure(DeserializationFeature.WRAP_EXCEPTIONS, Boolean.TRUE); Article article; try { ObjectNode node = (ObjectNode) mapper.readTree(serialized); node.remove("tags"); node.remove("locations"); node.remove("companies"); node.remove("topics"); node.remove("media"); node.remove("outboundUrls"); ObjectNode jsonNodes = (ObjectNode) node.get("source").get("feed"); jsonNodes.remove("editorialTopics"); jsonNodes.remove("tags"); jsonNodes.remove("autoTopics"); article = mapper.convertValue(node, Article.class); } catch (IOException ex) { throw new IllegalArgumentException("Unable to deserialize", ex); } return MoreoverUtils.convert(article); }
From source file:ac.simons.oembed.OembedJsonParser.java
public OembedJsonParser() { this.objectMapper = new ObjectMapper() .setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }