Package jodd.json
Class JsonContext
- java.lang.Object
-
- jodd.json.JsonWriter
-
- jodd.json.JsonContext
-
public class JsonContext extends JsonWriter
JSON context used during serialization for building the JSON string.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<JsonValueContext>bagprotected intbagSizeprotected booleanexcludeEmptyprotected booleanexcludeNullsprotected JsonSerializerjsonSerializerprotected JsonValueContextlastValueContextprotected Pathpathprotected java.util.function.Function<java.lang.Object,TypeJsonSerializer>serializerResolver-
Fields inherited from class jodd.json.JsonWriter
isPushed, out, pushedComma, pushedName, strictStringEncoding
-
-
Constructor Summary
Constructors Constructor Description JsonContext(JsonSerializer jsonSerializer, java.lang.Appendable appendable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonSerializergetJsonSerializer()ReturnsJsonSerializer.PathgetPath()Returns current path.booleanisExcludeEmpty()booleanisExcludeNulls()Returnstrueifnullvalues have to be excluded.booleanmatchIgnoredPropertyTypes(java.lang.Class propertyType, boolean excludeMaps, boolean include)Matches property types that are ignored by default.booleanmatchPathToQueries(boolean include)Matched current path to queries.JsonValueContextpeekValueContext()Returns currentvalue context.voidpopValue()Removes object from current bag, indicating it is not anymore in the path.voidpushName(java.lang.String name, boolean withComma)Stores name to temporary stack.booleanpushValue(java.lang.Object value)Returnstrueif object has been already processed during the serialization.booleanserialize(java.lang.Object object)Serializes the object usingtype serializer.voidwriteComma()Writes comma.-
Methods inherited from class jodd.json.JsonWriter
isNamePopped, popName, unicode, write, write, writeCloseArray, writeCloseObject, writeName, writeNumber, writeOpenArray, writeOpenObject, writeString
-
-
-
-
Field Detail
-
jsonSerializer
protected final JsonSerializer jsonSerializer
-
bag
protected final java.util.List<JsonValueContext> bag
-
bagSize
protected int bagSize
-
path
protected final Path path
-
excludeNulls
protected final boolean excludeNulls
-
excludeEmpty
protected final boolean excludeEmpty
-
serializerResolver
protected final java.util.function.Function<java.lang.Object,TypeJsonSerializer> serializerResolver
-
lastValueContext
protected JsonValueContext lastValueContext
-
-
Constructor Detail
-
JsonContext
public JsonContext(JsonSerializer jsonSerializer, java.lang.Appendable appendable)
-
-
Method Detail
-
getJsonSerializer
public JsonSerializer getJsonSerializer()
ReturnsJsonSerializer.
-
isExcludeNulls
public boolean isExcludeNulls()
Returnstrueifnullvalues have to be excluded.
-
isExcludeEmpty
public boolean isExcludeEmpty()
-
pushValue
public boolean pushValue(java.lang.Object value)
Returnstrueif object has been already processed during the serialization. Used to prevent circular dependencies. Objects are matched by identity.
-
popValue
public void popValue()
Removes object from current bag, indicating it is not anymore in the path.
-
peekValueContext
public JsonValueContext peekValueContext()
-
getPath
public Path getPath()
Returns current path.
-
pushName
public void pushName(java.lang.String name, boolean withComma)Stores name to temporary stack. Used when name's value may or may not be serialized (e.g. it may be excluded), in that case we do not need to write the name.- Overrides:
pushNamein classJsonWriter
-
writeComma
public void writeComma()
Writes comma.- Overrides:
writeCommain classJsonWriter
-
serialize
public boolean serialize(java.lang.Object object)
Serializes the object usingtype serializer. Returnstrueif object was written, otherwise returnsfalse.
-
matchIgnoredPropertyTypes
public boolean matchIgnoredPropertyTypes(java.lang.Class propertyType, boolean excludeMaps, boolean include)Matches property types that are ignored by default.
-
matchPathToQueries
public boolean matchPathToQueries(boolean include)
Matched current path to queries. If match is found, provided include value may be changed.
-
-