本文整理了Java中com.fasterxml.jackson.databind.ObjectMapper.addMixInAnnotations()
方法的一些代码示例,展示了ObjectMapper.addMixInAnnotations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper.addMixInAnnotations()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.ObjectMapper
类名称:ObjectMapper
方法名:addMixInAnnotations
暂无
代码示例来源:origin: fabric8io/kubernetes-client
public static ObjectMapper getStatelessMapper() {
if (statelessMapper == null) {
statelessMapper = new ObjectMapper(new YAMLFactory());
statelessMapper.addMixInAnnotations(ObjectMeta.class, ObjectMetaMixIn.class);
statelessMapper.addMixInAnnotations(ReplicationController.class, ReplicationControllerMixIn.class);
}
return statelessMapper;
}
代码示例来源:origin: kongchen/swagger-maven-plugin
mapper.addMixInAnnotations(Property.class, PropertyExampleMixIn.class);
代码示例来源:origin: com.conveyal/gtfs-lib
/**
* Add an additional mixin for serialization with this object mapper.
*/
public void addMixin(Class target, Class mixin) {
mapper.addMixInAnnotations(target, mixin);
}
代码示例来源:origin: jboss-fuse/fabric8
public static ObjectMapper getObjectMapper() {
if (mapper == null) {
mapper = new ObjectMapper();
mapper.addMixInAnnotations(CreateContainerMetadata.class, FieldsToIgnoreForDeserializationMixin.class);
mapper.addMixInAnnotations(CreateContainerOptions.class, FieldsToIgnoreForDeserializationMixin.class);
mapper.addMixInAnnotations(CreateContainerOptions.class, FieldsToIgnoreForSerializationMixin.class);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
return mapper;
}
}
代码示例来源:origin: org.springframework.social/spring-social-twitter
public StreamDispatcher(Queue<String> queue, List<StreamListener> listeners) {
this.queue = queue;
this.listeners = listeners;
pool = Executors.newCachedThreadPool();
objectMapper = new ObjectMapper();
objectMapper.addMixInAnnotations(Tweet.class, TweetMixin.class);
objectMapper.addMixInAnnotations(StreamDeleteEvent.class, StreamDeleteEventMixin.class);
objectMapper.addMixInAnnotations(StreamWarningEvent.class, StreamWarningEventMixin.class);
active = new AtomicBoolean(true);
}
代码示例来源:origin: stackoverflow.com
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper mapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(User.class, UserMixIn.class);
return mapper;
}
}
代码示例来源:origin: org.domeos/kubernetes-client
public static ObjectMapper getStatelessMapper() {
if (statelessMapper == null) {
statelessMapper = new ObjectMapper(new YAMLFactory());
statelessMapper.addMixInAnnotations(ObjectMeta.class, ObjectMetaMixIn.class);
statelessMapper.addMixInAnnotations(ReplicationController.class, ReplicationControllerMixIn.class);
}
return statelessMapper;
}
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
public static String dumpWithoutRuntimeStateAsYaml(HasMetadata obj) throws JsonProcessingException {
ObjectMapper statelessMapper = new ObjectMapper(new YAMLFactory());
statelessMapper.addMixInAnnotations(ObjectMeta.class, ObjectMetaMixIn.class);
statelessMapper.addMixInAnnotations(ReplicationController.class, StatelessReplicationControllerMixIn.class);
return statelessMapper.writeValueAsString(obj);
}
代码示例来源:origin: stackoverflow.com
abstract class Mixin<K, V> {
public Mixin(@JsonProperty("key") K key, @JsonProperty("value") V value) {}
}
...
public static <T> T fromJSON(String content, Class<T> clazz) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(SimpleEntry.class, Mixin.class);
return mapper.readValue(content, clazz);
}
代码示例来源:origin: stackoverflow.com
String json = "{\"bar\":\"Value\"}";
System.out.println(json);
ObjectMapper deserializeMapper = new ObjectMapper();
deserializeMapper.addMixInAnnotations(Foo.class, FooMixIn.class);
System.out.println(deserializeMapper.readValue(json, Foo.class));
代码示例来源:origin: stackoverflow.com
String json = "{\"bar\":\"Value\"}";
ObjectMapper deserializerMapper = new ObjectMapper();
Foo foo = deserializerMapper.readValue(json, Foo.class);
System.out.println("Foo object: " + foo);
ObjectMapper serializerMapper = new ObjectMapper();
serializerMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
serializerMapper.addMixInAnnotations(Foo.class, FooMixIn.class);
System.out.println("JSON: " + serializerMapper.writeValueAsString(foo));
代码示例来源:origin: openl-tablets/openl-tablets
private void addMixInAnnotations(ObjectMapper mapper, String className, Class<?> annotationClass) {
try {
mapper.addMixInAnnotations(loadClass(className), annotationClass);
} catch (ClassNotFoundException e) {
log.warn("Class '{}' hasn't been found!", className, e);
}
}
代码示例来源:origin: stackoverflow.com
PojoA pojoA = new PojoA();
pojoA.setB("B value");
System.out.println("Without MixIn:");
ObjectMapper mapper = new ObjectMapper();
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(pojoA));
System.out.println("With MixIn:");
ObjectMapper mapperWithMixIn = new ObjectMapper();
mapperWithMixIn.addMixInAnnotations(PojoA.class, PojoAMixIn.class);
System.out.println(mapperWithMixIn.writerWithDefaultPrettyPrinter().writeValueAsString(pojoA));
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws IOException {
ObjectMapper om = new ObjectMapper();
List<Common> list = new JacksonList<Common>();
list.add(new A());
list.add(new B());
om.addMixInAnnotations(A.class, AMixIn.class);
om.addMixInAnnotations(B.class, BMixIn.class);
System.out.println(om.writeValueAsString(list));
System.out.println(om.writeValueAsString(new A()));
}
代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet
private ObjectMapper getJsonMapper() {
ObjectMapper mapper = ObjectMapperFactory.createJson();
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
if (options.isJsonExampleValues()) {
mapper.addMixInAnnotations(Schema.class, PropertyExampleMixIn.class);
}
return mapper;
}
代码示例来源:origin: stackoverflow.com
Data data = new Data();
data.setName("Tom");
Root root = new Root();
root.setData(data);
ObjectMapper mapperWithMixIn = new ObjectMapper();
mapperWithMixIn.addMixInAnnotations(Root.class, RootMixIn.class);
ObjectMapper mapperDefault = new ObjectMapper();
System.out.println("With MIX-IN");
System.out.println(mapperWithMixIn.writeValueAsString(root));
System.out.println("Default");
System.out.println(mapperDefault.writeValueAsString(root));
代码示例来源:origin: org.domeos/kubernetes-client
public static ObjectMapper patchMapper() {
if (patchMapper == null) {
patchMapper = new ObjectMapper();
patchMapper.addMixInAnnotations(ObjectMeta.class, ObjectMetaMixIn.class);
patchMapper.addMixInAnnotations(Build.class, BuildMixIn.class);
patchMapper.setConfig(patchMapper().getSerializationConfig().without(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS));
}
return patchMapper;
}
代码示例来源:origin: StripesFramework/stripes
@Override
public void build(Writer writer) throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.addMixInAnnotations(Object.class, DynamicPropertyFilterMixin.class);
FilterProvider filterProvider = new SimpleFilterProvider()
.addFilter("dynamicPropertyFilter",
SimpleBeanPropertyFilter.serializeAllExcept(getExcludedProperties()));
mapper.writer(filterProvider).writeValue(writer, getRootObject());
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws JsonProcessingException {
Person p = new Person("Foo","Bar");
p.setAddress("This address is too long");
p.setAge(20);
ObjectMapper xmlMapper = new XmlMapper();
xmlMapper.addMixInAnnotations(Person.class, MixIn.class);
String xml = xmlMapper.writeValueAsString(p);
System.out.println(xml);
}
代码示例来源:origin: spring-projects/spring-xd-samples
/**
* Configure ObjectMapper to filter out fields causing serialization problems
*/
public SyndEntryJsonTransformer() {
mapper = new ObjectMapper();
mapper.addMixInAnnotations(SyndEntry.class,this.getClass());
FilterProvider filterProvider = new SimpleFilterProvider()
.addFilter("foreignMarkup filter", SimpleBeanPropertyFilter.serializeAllExcept("foreignMarkup"));
mapper.setFilters(filterProvider);
}
内容来源于网络,如有侵权,请联系作者删除!