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


Java JsonSerializer.serializeWithType方法代码示例

本文整理汇总了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);
    }
    
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:40,代码来源:UniqueIdPropertyWriter.java

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

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

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

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

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


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