本文整理了Java中org.codehaus.jackson.map.JsonSerializer.serializeWithType()
方法的一些代码示例,展示了JsonSerializer.serializeWithType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSerializer.serializeWithType()
方法的具体详情如下:
包路径:org.codehaus.jackson.map.JsonSerializer
类名称:JsonSerializer
方法名:serializeWithType
[英]Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.
Default implementation will ignore serialization of type information, and just calls #serialize: serializers that can embed type information should override this to implement actual handling. Most common such handling is done by something like:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array!
typeSer.writeTypePrefixForScalar(value, jgen);
serialize(value, jgen, provider);
typeSer.writeTypeSuffixForScalar(value, jgen);
[中]方法,可调用该方法要求实现序列化此序列化程序处理的类型的值,使用指定的类型序列化程序嵌入必要的类型信息。
默认实现将忽略类型信息的序列化,而只调用#serialize:可以嵌入类型信息的序列化程序应该覆盖它以实现实际处理。最常见的此类处理方式如下:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array!
typeSer.writeTypePrefixForScalar(value, jgen);
serialize(value, jgen, provider);
typeSer.writeTypeSuffixForScalar(value, jgen);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException
{
_serializer.serializeWithType(value, jgen, provider, _typeSerializer);
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
@Override
public void serializeWithType(Object value, JsonGenerator jgen, SerializerProvider provider,
TypeSerializer typeSer)
throws IOException, JsonProcessingException
{
/* Is this an erroneous call? For now, let's assume it is not, and
* that type serializer is just overridden if so
*/
_serializer.serializeWithType(value, jgen, provider, typeSer);
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
public void serializeContentsUsing(Collection<?> value, JsonGenerator jgen, SerializerProvider provider,
JsonSerializer<Object> ser)
throws IOException, JsonGenerationException
{
Iterator<?> it = value.iterator();
if (it.hasNext()) {
TypeSerializer typeSer = _valueTypeSerializer;
int i = 0;
do {
Object elem = it.next();
try {
if (elem == null) {
provider.defaultSerializeNull(jgen);
} else {
if (typeSer == null) {
ser.serialize(elem, jgen, provider);
} else {
ser.serializeWithType(elem, jgen, provider, typeSer);
}
}
++i;
} catch (Exception e) {
// [JACKSON-55] Need to add reference information
wrapAndThrow(provider, e, value, i);
}
} while (it.hasNext());
}
}
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
currSerializer.serialize(elem, jgen, provider);
} else {
currSerializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
currSerializer.serialize(elem, jgen, provider);
} else {
currSerializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
public void serializeContentsUsing(List<?> value, JsonGenerator jgen, SerializerProvider provider,
JsonSerializer<Object> ser)
throws IOException, JsonGenerationException
{
final int len = value.size();
if (len == 0) {
return;
}
final TypeSerializer typeSer = _valueTypeSerializer;
for (int i = 0; i < len; ++i) {
Object elem = value.get(i);
try {
if (elem == null) {
provider.defaultSerializeNull(jgen);
} else if (typeSer == null) {
ser.serialize(elem, jgen, provider);
} else {
ser.serializeWithType(elem, jgen, provider, typeSer);
}
} catch (Exception e) {
// [JACKSON-55] Need to add reference information
wrapAndThrow(provider, e, value, i);
}
}
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
ser.serialize(elem, jgen, provider);
} else {
ser.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
serializer = _findAndAddDynamic(serializers, cc, provider);
serializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
typeSer.writeTypePrefixForScalar(bean, jgen);
ser.serializeWithType(value, jgen, provider, typeSer);
if (_forceTypeInformation) {
typeSer.writeTypeSuffixForScalar(bean, jgen);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
currSerializer.serializeWithType(valueElem, jgen, provider, _valueTypeSerializer);
} catch (Exception e) {
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
ser.serialize(valueElem, jgen, provider);
} else {
ser.serializeWithType(valueElem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
serializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
serializer.serialize(elem, jgen, provider);
} else {
serializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
ser.serialize(value, jgen, prov);
} else {
ser.serializeWithType(value, jgen, prov, _typeSerializer);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
ser.serialize(value, jgen, prov);
} else {
ser.serializeWithType(value, jgen, prov, _typeSerializer);
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException
{
_serializer.serializeWithType(value, jgen, provider, _typeSerializer);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void serializeWithType(Object value, JsonGenerator jgen, SerializerProvider provider,
TypeSerializer typeSer)
throws IOException, JsonProcessingException
{
/* Is this an erroneous call? For now, let's assume it is not, and
* that type serializer is just overridden if so
*/
_serializer.serializeWithType(value, jgen, provider, typeSer);
}
代码示例来源:origin: camunda/camunda-bpm-platform
currSerializer.serialize(elem, jgen, provider);
} else {
currSerializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: camunda/camunda-bpm-platform
currSerializer.serialize(elem, jgen, provider);
} else {
currSerializer.serializeWithType(elem, jgen, provider, typeSer);
代码示例来源:origin: camunda/camunda-bpm-platform
public void serializeContentsUsing(List<?> value, JsonGenerator jgen, SerializerProvider provider,
JsonSerializer<Object> ser)
throws IOException, JsonGenerationException
{
final int len = value.size();
if (len == 0) {
return;
}
final TypeSerializer typeSer = _valueTypeSerializer;
for (int i = 0; i < len; ++i) {
Object elem = value.get(i);
try {
if (elem == null) {
provider.defaultSerializeNull(jgen);
} else if (typeSer == null) {
ser.serialize(elem, jgen, provider);
} else {
ser.serializeWithType(elem, jgen, provider, typeSer);
}
} catch (Exception e) {
// [JACKSON-55] Need to add reference information
wrapAndThrow(provider, e, value, i);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!