public class JsonSerializerSession extends WriterSerializerSession
JsonSerializer
.
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused within the same thread.
indent
Modifier | Constructor and Description |
---|---|
protected |
JsonSerializerSession(JsonSerializer ctx,
SerializerSessionArgs args)
Create a new session using properties specified in the context.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doSerialize(SerializerPipe out,
Object o)
Serializes a POJO to the specified output stream or writer.
|
protected JsonClassMeta |
getJsonClassMeta(ClassMeta<?> cm)
Returns the language-specific metadata on the specified class.
|
protected JsonWriter |
getJsonWriter(SerializerPipe out)
Converts the specified output target object to an
JsonWriter . |
protected boolean |
isAddBeanTypes()
Configuration property: Add
|
protected boolean |
isEscapeSolidus()
Configuration property: Prefix solidus
|
protected boolean |
isSimpleMode()
Configuration property: Simple JSON mode.
|
protected JsonWriter |
serializeAnything(JsonWriter out,
Object o,
ClassMeta<?> eType,
String attrName,
BeanPropertyMeta pMeta)
Workhorse method.
|
protected String |
serializeJson(Object o)
Method that can be called from subclasses to serialize an object to JSON.
|
OMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
createPipe, getMaxIndent, getQuoteChar, isUseWhitespace, isWriterSerializer, serialize, serializeToString
canIgnoreValue, createBeanTypeNameProperty, createDefaultVarResolverSession, generalize, getBeanTypeName, getExpectedRootType, getJavaMethod, getListener, getListener, getResponseHeaders, getUriContext, getUriRelativity, getUriResolution, getUriResolver, getVarResolver, isAddRootType, isKeepNullProperties, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, onBeanGetterException, onError, push2, relativizeUri, resolve, resolveUri, serialize, sort, sort, swap, toList, toString, trim, varSessionObject
getInitialDepth, getLastLocation, getMaxDepth, getOptionalType, getOptionalValue, getStack, isDetectRecursions, isIgnoreRecursions, isOptional, isRoot, pop, push, setCurrentClass, setCurrentProperty, willExceedDepth, willRecurse
_class, addWarning, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getExamples, getImplClasses, getNamePropertyName, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPropertyNamer, getSchema, getStringBuilder, getSwaps, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLocale, getMediaType, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getTimeZone, getTimeZoneId, getWarnings, hasProperty, hasWarnings, isDebug, toString
protected JsonSerializerSession(JsonSerializer ctx, SerializerSessionArgs args)
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.args
- Runtime arguments.
These specify session-level information such as locale and URI context.
It also include session-level properties that override the properties defined on the bean and
serializer contexts.protected void doSerialize(SerializerPipe out, Object o) throws IOException, SerializeException
SerializerSession
This method should NOT close the context object.
doSerialize
in class SerializerSession
out
- Where to send the output from the serializer.o
- The object to serialize.IOException
- Thrown by underlying stream.SerializeException
- Problem occurred trying to serialize object.protected String serializeJson(Object o) throws Exception
Used by JsonSchemaSerializerSession
for serializing examples to JSON.
o
- The object to serialize.Exception
- Error occurred.protected JsonWriter serializeAnything(JsonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) throws IOException, SerializeException
out
- The output writer.o
- The object to serialize.eType
- The expected type.attrName
- The attribute name.pMeta
- The bean property currently being parsed.IOException
- Thrown by underlying stream.SerializeException
- General serialization error occurred.protected final JsonWriter getJsonWriter(SerializerPipe out) throws IOException
JsonWriter
.out
- The output target object.JsonWriter
.IOException
- Thrown by underlying stream.protected final boolean isAddBeanTypes()
isAddBeanTypes
in class SerializerSession
JsonSerializer.JSON_addBeanTypes
protected final boolean isEscapeSolidus()
JsonSerializer.JSON_escapeSolidus
protected final boolean isSimpleMode()
JsonSerializer.JSON_simpleMode
protected JsonClassMeta getJsonClassMeta(ClassMeta<?> cm)
cm
- The class to return the metadata on.public OMap toMap()
Session
toMap
in class WriterSerializerSession
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.