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


Java JsonSerializer.serialize方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:18,代码来源:ArraySerializers.java

示例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);
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:StringCollectionSerializer.java

示例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);
    }
    
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:40,代码来源:UniqueIdPropertyWriter.java

示例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() + "()");
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:31,代码来源:JsonValueSerializer.java

示例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);
      }
    }
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:41,代码来源:ContainerSerializers.java

示例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);
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:14,代码来源:ContainerSerializers.java

示例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);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:40,代码来源:StdSerializerProvider.java

示例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);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:36,代码来源:BeanPropertyWriter.java

示例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());
    }
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:29,代码来源:EnumMapSerializer.java

示例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;
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:29,代码来源:IndexedStringListSerializer.java

示例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++;
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:39,代码来源:ObjectArraySerializer.java

示例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);
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:50,代码来源:MapSerializer.java


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