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 Details

    • jsonSerializer

      protected final JsonSerializer jsonSerializer
    • bag

      protected final 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 Function<Object, TypeJsonSerializer> serializerResolver
    • lastValueContext

      protected JsonValueContext lastValueContext
  • Constructor Details

  • Method Details

    • getJsonSerializer

      public JsonSerializer getJsonSerializer()
    • isExcludeNulls

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

      public boolean isExcludeEmpty()
    • pushValue

      public boolean pushValue(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.
    • peekValueContext

      public JsonValueContext peekValueContext()
      Returns current value context. It may be null if value is not pushed yet.
    • getPath

      public Path getPath()
      Returns current path.
    • pushName

      public void pushName(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
    • writeComma

      public void writeComma()
      Writes comma.
      Overrides:
      writeComma in class JsonWriter
    • serialize

      public boolean serialize(Object object)
      Serializes the object using type serializer. Returns true if object was written, otherwise returns false.
    • matchIgnoredPropertyTypes

      public boolean matchIgnoredPropertyTypes(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.