Package org.apache.juneau.json
Class JsonSerializerSession
java.lang.Object
org.apache.juneau.ContextSession
org.apache.juneau.BeanSession
org.apache.juneau.BeanTraverseSession
org.apache.juneau.serializer.SerializerSession
org.apache.juneau.serializer.WriterSerializerSession
org.apache.juneau.json.JsonSerializerSession
- Direct Known Subclasses:
- JsonSchemaSerializerSession
Session object that lives for the duration of a single use of 
JsonSerializer.
 Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields inherited from class org.apache.juneau.BeanTraverseSessionindent
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedConstructor.
- 
Method SummaryModifier and TypeMethodDescriptioncreate(JsonSerializer ctx) Creates a new builder for this object.protected voiddoSerialize(SerializerPipe out, Object o) Serializes a POJO to the specified pipe.protected JsonClassMetagetJsonClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected final JsonWriterConverts the specified output target object to anJsonWriter.protected final booleanAdd"_type" properties when needed.protected final booleanPrefix solidus'/' characters with escapes.protected final booleanSimple JSON attributes.protected JsonWriterserializeAnything(JsonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) Workhorse method.protected StringMethod that can be called from subclasses to serialize an object to JSON.Methods inherited from class org.apache.juneau.serializer.WriterSerializerSessioncreate, createPipe, getFileCharset, getMaxIndent, getQuoteChar, getStreamCharset, isUseWhitespace, isWriterSerializer, properties, serialize, serializeToStringMethods inherited from class org.apache.juneau.serializer.SerializerSessionaddVarBean, canIgnoreValue, create, createBeanTypeNameProperty, createDefaultVarResolverSession, forEachEntry, forEachEntry, generalize, getBeanTypeName, getExpectedRootType, getJavaMethod, getListener, getListener, getResponseHeaders, getSchema, getUriContext, getUriRelativity, getUriResolution, getUriResolver, getVarResolver, handleThrown, isAddRootType, isKeepNullProperties, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, onBeanGetterException, onError, push2, relativizeUri, resolve, resolveUri, serialize, sort, sort, sort, swap, toList, toString, trimMethods inherited from class org.apache.juneau.BeanTraverseSessiongetInitialDepth, getLastLocation, getMaxDepth, getOptionalType, getOptionalValue, getStack, isDetectRecursions, isIgnoreRecursions, isOptional, isRoot, pop, push, setCurrentClass, setCurrentProperty, willExceedDepth, willRecurseMethods inherited from class org.apache.juneau.BeanSession_class, addWarning, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, create, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMediaType, getNamePropertyName, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, newGenericMap, object, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.ContextSessioncheckForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toString
- 
Constructor Details- 
JsonSerializerSessionConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
createCreates a new builder for this object.- Parameters:
- ctx- The context creating this session.
- Returns:
- A new builder.
 
- 
doSerializeDescription copied from class:SerializerSessionSerializes a POJO to the specified pipe.This method should NOT close the context object. The default implementation of this method simply calls Serializer.doSerialize(SerializerSession,SerializerPipe,Object).- Overrides:
- doSerializein class- SerializerSession
- Parameters:
- out- Where to send the output from the serializer.
- o- The object to serialize.
- Throws:
- IOException- Thrown by underlying stream.
- SerializeException- Problem occurred trying to serialize object.
 
- 
serializeJsonMethod that can be called from subclasses to serialize an object to JSON.Used by JsonSchemaSerializerSessionfor serializing examples to JSON.- Parameters:
- o- The object to serialize.
- Returns:
- The serialized object.
- Throws:
- Exception- Error occurred.
 
- 
serializeAnythingprotected JsonWriter serializeAnything(JsonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) throws SerializeException Workhorse method. Determines the type of object, and then calls the appropriate type-specific serialization method.- Parameters:
- out- The output writer.
- o- The object to serialize.
- eType- The expected type.
- attrName- The attribute name.
- pMeta- The bean property currently being parsed.
- Returns:
- The same writer passed in.
- Throws:
- SerializeException- General serialization error occurred.
 
- 
getJsonWriterConverts the specified output target object to anJsonWriter.- Parameters:
- out- The output target object.
- Returns:
- The output target object wrapped in an JsonWriter.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
isAddBeanTypesAdd"_type" properties when needed.- Overrides:
- isAddBeanTypesin class- SerializerSession
- Returns:
- true if- "_type" properties will be added to beans if their type cannot be inferred through reflection.
- See Also:
 
- 
isEscapeSolidusPrefix solidus'/' characters with escapes.- Returns:
- true if solidus (e.g. slash) characters should be escaped.
- See Also:
 
- 
isSimpleAttrsSimple JSON attributes.- Returns:
- true if JSON attribute names will only be quoted when necessary.
 Otherwise, they are always quoted.
- See Also:
 
- 
getJsonClassMetaReturns the language-specific metadata on the specified class.- Parameters:
- cm- The class to return the metadata on.
- Returns:
- The metadata.
 
 
-