本文整理汇总了Java中org.codehaus.jackson.map.JsonSerializer.serializeWithType方法的典型用法代码示例。如果您正苦于以下问题:Java JsonSerializer.serializeWithType方法的具体用法?Java JsonSerializer.serializeWithType怎么用?Java JsonSerializer.serializeWithType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.map.JsonSerializer
的用法示例。
在下文中一共展示了JsonSerializer.serializeWithType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeAsField
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
@Override
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov)
throws Exception
{
// _name is final so we have to do a little bit of trickery to change the field name.
Object value = get(bean);
// Null handling is bit different, check that first
if (value == null) {
if (!_suppressNulls) {
jgen.writeFieldName(_name);
prov.defaultSerializeNull(jgen);
}
return;
}
// For non-nulls, first: simple check for direct cycles
if (value == bean) {
_reportSelfReference(bean);
}
if (_suppressableValue != null && _suppressableValue.equals(value)) {
return;
}
JsonSerializer<Object> ser = _serializer;
if (ser == null) {
Class<?> cls = value.getClass();
PropertySerializerMap map = _dynamicSerializers;
ser = map.serializerFor(cls);
if (ser == null) {
ser = _findAndAddDynamic(map, cls, prov);
}
}
jgen.writeFieldName(UniqueId.UNIQUE_NAME);
if (_typeSerializer == null) {
ser.serialize(value, jgen, prov);
} else {
ser.serializeWithType(value, jgen, prov, _typeSerializer);
}
}
示例2: serializeContentsUsing
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serializeContentsUsing(Collection<?> paramCollection, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer)
throws IOException, JsonGenerationException
{
Iterator localIterator = paramCollection.iterator();
TypeSerializer localTypeSerializer;
int i;
if (localIterator.hasNext())
{
localTypeSerializer = this._valueTypeSerializer;
i = 0;
}
while (true)
{
Object localObject = localIterator.next();
if (localObject == null);
try
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
while (true)
{
i++;
if (localIterator.hasNext())
break;
return;
if (localTypeSerializer != null)
break label92;
paramJsonSerializer.serialize(localObject, paramJsonGenerator, paramSerializerProvider);
}
}
catch (Exception localException)
{
while (true)
{
wrapAndThrow(paramSerializerProvider, localException, paramCollection, i);
continue;
label92: paramJsonSerializer.serializeWithType(localObject, paramJsonGenerator, paramSerializerProvider, localTypeSerializer);
}
}
}
}
示例3: serializeAsField
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serializeAsField(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws Exception
{
Object localObject = get(paramObject);
if (localObject == null)
if (!this._suppressNulls)
{
paramJsonGenerator.writeFieldName(this._name);
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
}
do
{
return;
if (localObject != paramObject)
continue;
_reportSelfReference(paramObject);
}
while ((this._suppressableValue != null) && (this._suppressableValue.equals(localObject)));
JsonSerializer localJsonSerializer = this._serializer;
if (localJsonSerializer == null)
{
Class localClass = localObject.getClass();
PropertySerializerMap localPropertySerializerMap = this._dynamicSerializers;
localJsonSerializer = localPropertySerializerMap.serializerFor(localClass);
if (localJsonSerializer == null)
localJsonSerializer = _findAndAddDynamic(localPropertySerializerMap, localClass, paramSerializerProvider);
}
paramJsonGenerator.writeFieldName(this._name);
if (this._typeSerializer == null)
{
localJsonSerializer.serialize(localObject, paramJsonGenerator, paramSerializerProvider);
return;
}
localJsonSerializer.serializeWithType(localObject, paramJsonGenerator, paramSerializerProvider, this._typeSerializer);
}
示例4: serializeContentsUsing
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serializeContentsUsing(Object[] paramArrayOfObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer)
throws IOException, JsonGenerationException
{
int i = paramArrayOfObject.length;
TypeSerializer localTypeSerializer = this._valueTypeSerializer;
int j = 0;
Object localObject1 = null;
while (true)
{
if (j < i)
try
{
localObject1 = paramArrayOfObject[j];
if (localObject1 == null)
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
break label135;
}
if (localTypeSerializer == null)
paramJsonSerializer.serialize(localObject1, paramJsonGenerator, paramSerializerProvider);
}
catch (IOException localIOException)
{
throw localIOException;
paramJsonSerializer.serializeWithType(localObject1, paramJsonGenerator, paramSerializerProvider, localTypeSerializer);
}
catch (Exception localException)
{
for (Object localObject2 = localException; ((localObject2 instanceof InvocationTargetException)) && (((Throwable)localObject2).getCause() != null); localObject2 = ((Throwable)localObject2).getCause());
if ((localObject2 instanceof Error))
throw ((Error)localObject2);
throw JsonMappingException.wrapWithPath((Throwable)localObject2, localObject1, j);
}
else
return;
label135: j++;
}
}
示例5: serializeFieldsUsing
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
protected void serializeFieldsUsing(Map<?, ?> paramMap, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer)
throws IOException, JsonGenerationException
{
JsonSerializer localJsonSerializer = this._keySerializer;
HashSet localHashSet = this._ignoredEntries;
TypeSerializer localTypeSerializer = this._valueTypeSerializer;
int i;
Iterator localIterator;
if (!paramSerializerProvider.isEnabled(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES))
{
i = 1;
localIterator = paramMap.entrySet().iterator();
}
while (true)
{
label44: if (!localIterator.hasNext())
return;
Map.Entry localEntry = (Map.Entry)localIterator.next();
Object localObject1 = localEntry.getValue();
Object localObject2 = localEntry.getKey();
if (localObject2 == null)
paramSerializerProvider.getNullKeySerializer().serialize(null, paramJsonGenerator, paramSerializerProvider);
while (true)
{
if (localObject1 != null)
break label155;
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
break label44;
i = 0;
break;
if (((i != 0) && (localObject1 == null)) || ((localHashSet != null) && (localHashSet.contains(localObject2))))
break label44;
localJsonSerializer.serialize(localObject2, paramJsonGenerator, paramSerializerProvider);
}
label155: if (localTypeSerializer == null)
{
try
{
paramJsonSerializer.serialize(localObject1, paramJsonGenerator, paramSerializerProvider);
}
catch (Exception localException)
{
wrapAndThrow(paramSerializerProvider, localException, paramMap, "" + localObject2);
}
continue;
}
paramJsonSerializer.serializeWithType(localObject1, paramJsonGenerator, paramSerializerProvider, localTypeSerializer);
}
}
示例6: serializeTypedContents
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serializeTypedContents(Object[] paramArrayOfObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
int i = paramArrayOfObject.length;
TypeSerializer localTypeSerializer = this._valueTypeSerializer;
int j = 0;
Object localObject1 = null;
while (true)
{
try
{
PropertySerializerMap localPropertySerializerMap = this._dynamicSerializers;
if (j < i)
{
localObject1 = paramArrayOfObject[j];
if (localObject1 != null)
continue;
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
break label156;
Class localClass = localObject1.getClass();
JsonSerializer localJsonSerializer = localPropertySerializerMap.serializerFor(localClass);
if (localJsonSerializer != null)
continue;
localJsonSerializer = _findAndAddDynamic(localPropertySerializerMap, localClass, paramSerializerProvider);
localJsonSerializer.serializeWithType(localObject1, paramJsonGenerator, paramSerializerProvider, localTypeSerializer);
}
}
catch (IOException localIOException)
{
throw localIOException;
}
catch (Exception localException)
{
Object localObject2 = localException;
if ((!(localObject2 instanceof InvocationTargetException)) || (((Throwable)localObject2).getCause() == null))
continue;
localObject2 = ((Throwable)localObject2).getCause();
continue;
if (!(localObject2 instanceof Error))
continue;
throw ((Error)localObject2);
throw JsonMappingException.wrapWithPath((Throwable)localObject2, localObject1, j);
}
return;
label156: j++;
}
}