当前位置: 首页>>代码示例>>Java>>正文


Java Serializers类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ser.Serializers的典型用法代码示例。如果您正苦于以下问题:Java Serializers类的具体用法?Java Serializers怎么用?Java Serializers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Serializers类属于com.fasterxml.jackson.databind.ser包,在下文中一共展示了Serializers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SerializerFactoryConfig

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
protected SerializerFactoryConfig(Serializers[] paramArrayOfSerializers1, Serializers[] paramArrayOfSerializers2, BeanSerializerModifier[] paramArrayOfBeanSerializerModifier)
{
  Serializers[] arrayOfSerializers1;
  if (paramArrayOfSerializers1 == null)
    arrayOfSerializers1 = NO_SERIALIZERS;
  else
    arrayOfSerializers1 = paramArrayOfSerializers1;
  this._additionalSerializers = arrayOfSerializers1;
  Serializers[] arrayOfSerializers2;
  if (paramArrayOfSerializers2 == null)
    arrayOfSerializers2 = NO_SERIALIZERS;
  else
    arrayOfSerializers2 = paramArrayOfSerializers2;
  this._additionalKeySerializers = arrayOfSerializers2;
  BeanSerializerModifier[] arrayOfBeanSerializerModifier;
  if (paramArrayOfBeanSerializerModifier == null)
    arrayOfBeanSerializerModifier = NO_MODIFIERS;
  else
    arrayOfBeanSerializerModifier = paramArrayOfBeanSerializerModifier;
  this._modifiers = arrayOfBeanSerializerModifier;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:SerializerFactoryConfig.java

示例2: modules

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
public void modules() {
	NumberSerializer serializer1 = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer1);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(module).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer1, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:Jackson2ObjectMapperBuilderTests.java

示例3: modulesToInstallByClass

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void modulesToInstallByClass() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modulesToInstall(CustomIntegerModule.class).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class, serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:Jackson2ObjectMapperBuilderTests.java

示例4: serializerByType

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
public void serializerByType() {
	JsonSerializer<Number> serializer = new NumberSerializer(Integer.class);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.serializerByType(Boolean.class, serializer).build();
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:Jackson2ObjectMapperBuilderTests.java

示例5: setModules

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
public void setModules() {
	NumberSerializer serializer = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer);

	this.factory.setModules(Arrays.asList(new Module[]{module}));
	this.factory.afterPropertiesSet();
	ObjectMapper objectMapper = this.factory.getObject();

	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:Jackson2ObjectMapperFactoryBeanTests.java

示例6: withAdditionalKeySerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
public final SerializerFactoryConfig withAdditionalKeySerializers(Serializers paramSerializers)
{
  if (paramSerializers == null)
    throw new IllegalArgumentException("Can not pass null Serializers");
  Serializers[] arrayOfSerializers = (Serializers[])ArrayBuilders.insertInListNoDup(this._additionalKeySerializers, paramSerializers);
  return new SerializerFactoryConfig(this._additionalSerializers, arrayOfSerializers, this._modifiers);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:8,代码来源:SerializerFactoryConfig.java

示例7: findSerializer

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
public JsonSerializer<?> findSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, BeanDescription paramBeanDescription)
{
  Class localClass = paramJavaType.getRawClass();
  if ((localClass.getName().startsWith("javax.xml.")) || (!hasSupertypeStartingWith(localClass, "javax.xml.")))
  {
    if (doesImplement(localClass, "org.w3c.dom.Node"))
      return (JsonSerializer)instantiate("com.fasterxml.jackson.databind.ext.DOMSerializer");
    return null;
  }
  Object localObject = instantiate("com.fasterxml.jackson.databind.ext.CoreXMLSerializers");
  if (localObject == null)
    return null;
  return ((Serializers)localObject).findSerializer(paramSerializationConfig, paramJavaType, paramBeanDescription);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:15,代码来源:OptionalHandlerFactory.java

示例8: modulesToInstallByInstance

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
public void modulesToInstallByInstance() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modulesToInstall(new CustomIntegerModule()).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class, serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:Jackson2ObjectMapperBuilderTests.java

示例9: completeSetup

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Test
public void completeSetup() {
	NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
	ObjectMapper objectMapper = new ObjectMapper();

	this.factory.setObjectMapper(objectMapper);
	assertTrue(this.factory.isSingleton());
	assertEquals(ObjectMapper.class, this.factory.getObjectType());

	Map<Class<?>, JsonDeserializer<?>> deserializers = new HashMap<Class<?>, JsonDeserializer<?>>();
	deserializers.put(Date.class, new DateDeserializer());

	JsonSerializer<Class<?>> serializer1 = new ClassSerializer();
	JsonSerializer<Number> serializer2 = new NumberSerializer(Integer.class);

	// Disable well-known modules detection
	this.factory.setModules(new ArrayList<>());
	this.factory.setSerializers(serializer1);
	this.factory.setSerializersByType(Collections.singletonMap(Boolean.class, serializer2));
	this.factory.setDeserializersByType(deserializers);
	this.factory.setAnnotationIntrospector(annotationIntrospector);

	this.factory.setFeaturesToEnable(SerializationFeature.FAIL_ON_EMPTY_BEANS,
			DeserializationFeature.UNWRAP_ROOT_VALUE,
			JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER,
			JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);

	this.factory.setFeaturesToDisable(MapperFeature.AUTO_DETECT_GETTERS,
			MapperFeature.AUTO_DETECT_FIELDS,
			JsonParser.Feature.AUTO_CLOSE_SOURCE,
			JsonGenerator.Feature.QUOTE_FIELD_NAMES);

	assertFalse(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertFalse(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	this.factory.setSerializationInclusion(Include.NON_NULL);
	this.factory.afterPropertiesSet();

	assertSame(objectMapper, this.factory.getObject());
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer1, serializers.findSerializer(null, SimpleType.construct(Class.class), null));
	assertSame(serializer2, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
	assertNull(serializers.findSerializer(null, SimpleType.construct(Number.class), null));

	assertSame(annotationIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector());
	assertSame(annotationIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector());

	assertTrue(objectMapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS));
	assertTrue(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
	assertTrue(objectMapper.getFactory().isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
	assertTrue(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));

	assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
	assertFalse(objectMapper.getFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE));
	assertFalse(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES));
	assertSame(Include.NON_NULL, objectMapper.getSerializationConfig().getSerializationInclusion());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:64,代码来源:Jackson2ObjectMapperFactoryBeanTests.java

示例10: keySerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
public final Iterable<Serializers> keySerializers()
{
  return ArrayBuilders.arrayAsIterable(this._additionalKeySerializers);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:SerializerFactoryConfig.java

示例11: serializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
public final Iterable<Serializers> serializers()
{
  return ArrayBuilders.arrayAsIterable(this._additionalSerializers);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:SerializerFactoryConfig.java

示例12: withAdditionalSerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
public final SerializerFactoryConfig withAdditionalSerializers(Serializers paramSerializers)
{
  if (paramSerializers == null)
    throw new IllegalArgumentException("Can not pass null Serializers");
  return new SerializerFactoryConfig((Serializers[])ArrayBuilders.insertInListNoDup(this._additionalSerializers, paramSerializers), this._additionalKeySerializers, this._modifiers);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:7,代码来源:SerializerFactoryConfig.java

示例13: customSerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
@Override
protected Iterable<Serializers> customSerializers() {
	return null;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:5,代码来源:MappingJackson2JsonViewTests.java

示例14: addSerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
/**
 * Method that module can use to register additional serializers to use for
 * handling types.
 * 
 * @param s Object that can be called to find serializer for types supported
 *   by module (null returned for non-supported types)
 */
public void addSerializers(Serializers s);
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:9,代码来源:Module.java

示例15: addKeySerializers

import com.fasterxml.jackson.databind.ser.Serializers; //导入依赖的package包/类
/**
 * Method that module can use to register additional serializers to use for
 * handling Map key values (which are separate from value serializers because
 * they must write <code>JsonToken.FIELD_NAME</code> instead of String value).
 */
public void addKeySerializers(Serializers s);
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:7,代码来源:Module.java


注:本文中的com.fasterxml.jackson.databind.ser.Serializers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。