Class JsonWriter

java.lang.Object
net.minidev.json.reader.JsonWriter

public class JsonWriter extends Object
  • Field Details

  • Constructor Details

    • JsonWriter

      public JsonWriter()
  • Method Details

    • remapField

      public <T> void remapField(Class<T> type, String fromJava, String toJson)
      remap field name in custom classes
      Parameters:
      fromJava - field name in java
      toJson - field name in json
      Since:
      2.1.1
    • getWriterByInterface

      public JsonWriterI getWriterByInterface(Class<?> clazz)
      try to find a Writer by Checking implemented interface
      Parameters:
      clazz - class to serialize
      Returns:
      a Writer or null
    • getWrite

      public JsonWriterI getWrite(Class cls)
    • init

      public void init()
    • addInterfaceWriterFirst

      public void addInterfaceWriterFirst(Class<?> interFace, JsonWriterI<?> writer)
      Deprecated.
      use registerWriterInterfaceFirst
      associate an Writer to a interface With Hi priority
      Parameters:
      interFace - interface to map
      writer - writer Object
    • addInterfaceWriterLast

      public void addInterfaceWriterLast(Class<?> interFace, JsonWriterI<?> writer)
      Deprecated.
      use registerWriterInterfaceLast
      associate an Writer to a interface With Low priority
      Parameters:
      interFace - interface to map
      writer - writer Object
    • registerWriterInterfaceLast

      public void registerWriterInterfaceLast(Class<?> interFace, JsonWriterI<?> writer)
      associate an Writer to a interface With Low priority
      Parameters:
      interFace - interface to map
      writer - writer Object
    • registerWriterInterfaceFirst

      public void registerWriterInterfaceFirst(Class<?> interFace, JsonWriterI<?> writer)
      associate an Writer to a interface With Hi priority
      Parameters:
      interFace - interface to map
      writer - writer Object
    • registerWriterInterface

      public void registerWriterInterface(Class<?> interFace, JsonWriterI<?> writer)
      an alias for registerWriterInterfaceLast
      Parameters:
      interFace - interface to map
      writer - writer Object
    • registerWriter

      public <T> void registerWriter(JsonWriterI<T> writer, Class<?>... cls)
      associate an Writer to a Class
      Parameters:
      writer -
      cls -
    • writeJSONKV

      public static void writeJSONKV(String key, Object value, Appendable out, JSONStyle compression) throws IOException
      Write a Key : value entry to a stream
      Throws:
      IOException