本文整理汇总了Java中org.codehaus.jackson.map.JsonSerializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java JsonSerializer.serialize方法的具体用法?Java JsonSerializer.serialize怎么用?Java JsonSerializer.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.map.JsonSerializer
的用法示例。
在下文中一共展示了JsonSerializer.serialize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeContentsSlow
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
private void serializeContentsSlow(String[] paramArrayOfString, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer)
throws IOException, JsonGenerationException
{
int i = 0;
int j = paramArrayOfString.length;
if (i < j)
{
if (paramArrayOfString[i] == null)
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
while (true)
{
i++;
break;
paramJsonSerializer.serialize(paramArrayOfString[i], paramJsonGenerator, paramSerializerProvider);
}
}
}
示例2: serializeUsingCustom
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
private void serializeUsingCustom(Collection<String> paramCollection, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
JsonSerializer localJsonSerializer = this._serializer;
Iterator localIterator = paramCollection.iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
if (str == null)
{
try
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
}
catch (Exception localException)
{
wrapAndThrow(paramSerializerProvider, localException, paramCollection, 0);
}
continue;
}
localJsonSerializer.serialize(str, paramJsonGenerator, paramSerializerProvider);
}
}
示例3: 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);
}
}
示例4: serialize
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serialize(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
Object localObject1;
try
{
Object localObject2 = this._accessorMethod.invoke(paramObject, new Object[0]);
if (localObject2 == null)
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
return;
}
JsonSerializer localJsonSerializer = this._valueSerializer;
if (localJsonSerializer == null)
localJsonSerializer = paramSerializerProvider.findTypedValueSerializer(localObject2.getClass(), true, this._property);
localJsonSerializer.serialize(localObject2, paramJsonGenerator, paramSerializerProvider);
return;
}
catch (IOException localIOException)
{
throw localIOException;
}
catch (Exception localException)
{
for (localObject1 = localException; ((localObject1 instanceof InvocationTargetException)) && (((Throwable)localObject1).getCause() != null); localObject1 = ((Throwable)localObject1).getCause());
if ((localObject1 instanceof Error))
throw ((Error)localObject1);
}
throw JsonMappingException.wrapWithPath((Throwable)localObject1, paramObject, this._accessorMethod.getName() + "()");
}
示例5: 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);
}
}
}
}
示例6: serializeContents
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
public void serializeContents(EnumSet<? extends Enum<?>> paramEnumSet, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
JsonSerializer localJsonSerializer = this._elementSerializer;
Iterator localIterator = paramEnumSet.iterator();
while (localIterator.hasNext())
{
Enum localEnum = (Enum)localIterator.next();
if (localJsonSerializer == null)
localJsonSerializer = paramSerializerProvider.findValueSerializer(localEnum.getDeclaringClass(), this._property);
localJsonSerializer.serialize(localEnum, paramJsonGenerator, paramSerializerProvider);
}
}
示例7: _serializeValue
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
protected void _serializeValue(JsonGenerator paramJsonGenerator, Object paramObject)
throws IOException, JsonProcessingException
{
JsonSerializer localJsonSerializer;
boolean bool;
if (paramObject == null)
{
localJsonSerializer = getNullValueSerializer();
bool = false;
}
String str;
try
{
while (true)
{
localJsonSerializer.serialize(paramObject, paramJsonGenerator, this);
if (bool)
paramJsonGenerator.writeEndObject();
return;
localJsonSerializer = findTypedValueSerializer(paramObject.getClass(), true, null);
bool = this._config.isEnabled(SerializationConfig.Feature.WRAP_ROOT_VALUE);
if (!bool)
continue;
paramJsonGenerator.writeStartObject();
paramJsonGenerator.writeFieldName(this._rootNames.findRootName(paramObject.getClass(), this._config));
}
}
catch (IOException localIOException)
{
throw localIOException;
}
catch (Exception localException)
{
str = localException.getMessage();
if (str == null)
str = "[no message for " + localException.getClass().getName() + "]";
}
throw new JsonMappingException(str, localException);
}
示例8: 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);
}
示例9: serializeContentsUsing
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
protected void serializeContentsUsing(EnumMap<? extends Enum<?>, ?> paramEnumMap, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer)
throws IOException, JsonGenerationException
{
EnumValues localEnumValues = this._keyEnums;
Iterator localIterator = paramEnumMap.entrySet().iterator();
while (localIterator.hasNext())
{
Map.Entry localEntry = (Map.Entry)localIterator.next();
Enum localEnum = (Enum)localEntry.getKey();
if (localEnumValues == null)
localEnumValues = ((EnumSerializer)(SerializerBase)paramSerializerProvider.findValueSerializer(localEnum.getDeclaringClass(), this._property)).getEnumValues();
paramJsonGenerator.writeFieldName(localEnumValues.serializedValueFor(localEnum));
Object localObject = localEntry.getValue();
if (localObject == null)
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
continue;
}
try
{
paramJsonSerializer.serialize(localObject, paramJsonGenerator, paramSerializerProvider);
}
catch (Exception localException)
{
wrapAndThrow(paramSerializerProvider, localException, paramEnumMap, ((Enum)localEntry.getKey()).name());
}
}
}
示例10: serializeUsingCustom
import org.codehaus.jackson.map.JsonSerializer; //导入方法依赖的package包/类
private final void serializeUsingCustom(List<String> paramList, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
for (int i = 0; ; i++)
{
try
{
int j = paramList.size();
JsonSerializer localJsonSerializer = this._serializer;
i = 0;
if (i < j)
{
String str = (String)paramList.get(i);
if (str == null)
{
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
continue;
}
localJsonSerializer.serialize(str, paramJsonGenerator, paramSerializerProvider);
}
}
catch (Exception localException)
{
wrapAndThrow(paramSerializerProvider, localException, paramList, i);
}
return;
}
}
示例11: 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++;
}
}
示例12: 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);
}
}