Package jodd.json

Class JsonContext


  • public class JsonContext
    extends JsonWriter
    JSON context used during serialization for building the JSON string.
    • Field Detail

      • 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
    • Constructor Detail

      • JsonContext

        public JsonContext​(JsonSerializer jsonSerializer,
                           java.lang.Appendable appendable)
    • Method Detail

      • isExcludeNulls

        public boolean isExcludeNulls()
        Returns true if null values have to be excluded.
      • isExcludeEmpty

        public boolean isExcludeEmpty()
      • pushValue

        public boolean pushValue​(java.lang.Object value)
        Returns true if 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.
      • 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:
        pushName in class JsonWriter
      • serialize

        public boolean serialize​(java.lang.Object object)
        Serializes the object using type serializer. Returns true if object was written, otherwise returns false.
      • 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.