Package net.minidev.json.reader
Class JsonWriter
- java.lang.Object
-
- net.minidev.json.reader.JsonWriter
-
public class JsonWriter extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
JsonWriter.WriterByInterface
-
Field Summary
Fields Modifier and Type Field Description static JsonWriterI<java.lang.Object>
arrayWriter
Json-Smart ArrayWriterClassstatic JsonWriterI<java.lang.Object>
beansWriter
Json-Smart V1 Beans serialiserstatic JsonWriterI<java.lang.Object>
beansWriterASM
Json-Smart V2 Beans serialiser Based on ASMprivate java.util.concurrent.ConcurrentHashMap<java.lang.Class<?>,JsonWriterI<?>>
data
static JsonWriterI<java.lang.Enum<?>>
EnumWriter
static JsonWriterI<java.lang.Iterable<? extends java.lang.Object>>
JSONIterableWriter
static JsonWriterI<JSONAwareEx>
JSONJSONAwareExWriter
static JsonWriterI<JSONAware>
JSONJSONAwareWriter
static JsonWriterI<java.util.Map<java.lang.String,? extends java.lang.Object>>
JSONMapWriter
static JsonWriterI<JSONStreamAwareEx>
JSONStreamAwareExWriter
static JsonWriterI<JSONStreamAwareEx>
JSONStreamAwareWriter
static JsonWriterI<java.lang.Object>
toStringWriter
ToString Writerprivate java.util.LinkedList<JsonWriter.WriterByInterface>
writerInterfaces
-
Constructor Summary
Constructors Constructor Description JsonWriter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addInterfaceWriterFirst(java.lang.Class<?> interFace, JsonWriterI<?> writer)
Deprecated.use registerWriterInterfaceFirstvoid
addInterfaceWriterLast(java.lang.Class<?> interFace, JsonWriterI<?> writer)
Deprecated.use registerWriterInterfaceLastJsonWriterI
getWrite(java.lang.Class cls)
JsonWriterI
getWriterByInterface(java.lang.Class<?> clazz)
try to find a Writer by Cheking implemented interfacevoid
init()
<T> void
registerWriter(JsonWriterI<T> writer, java.lang.Class<?>... cls)
associate an Writer to a Classvoid
registerWriterInterface(java.lang.Class<?> interFace, JsonWriterI<?> writer)
an alias for registerWriterInterfaceLastvoid
registerWriterInterfaceFirst(java.lang.Class<?> interFace, JsonWriterI<?> writer)
associate an Writer to a interface With Hi priorityvoid
registerWriterInterfaceLast(java.lang.Class<?> interFace, JsonWriterI<?> writer)
associate an Writer to a interface With Low priority<T> void
remapField(java.lang.Class<T> type, java.lang.String fromJava, java.lang.String toJson)
remap field name in custom classesstatic void
writeJSONKV(java.lang.String key, java.lang.Object value, java.lang.Appendable out, JSONStyle compression)
Write a Key : value entry to a stream
-
-
-
Field Detail
-
data
private java.util.concurrent.ConcurrentHashMap<java.lang.Class<?>,JsonWriterI<?>> data
-
writerInterfaces
private java.util.LinkedList<JsonWriter.WriterByInterface> writerInterfaces
-
JSONStreamAwareWriter
public static final JsonWriterI<JSONStreamAwareEx> JSONStreamAwareWriter
-
JSONStreamAwareExWriter
public static final JsonWriterI<JSONStreamAwareEx> JSONStreamAwareExWriter
-
JSONJSONAwareExWriter
public static final JsonWriterI<JSONAwareEx> JSONJSONAwareExWriter
-
JSONJSONAwareWriter
public static final JsonWriterI<JSONAware> JSONJSONAwareWriter
-
JSONIterableWriter
public static final JsonWriterI<java.lang.Iterable<? extends java.lang.Object>> JSONIterableWriter
-
EnumWriter
public static final JsonWriterI<java.lang.Enum<?>> EnumWriter
-
JSONMapWriter
public static final JsonWriterI<java.util.Map<java.lang.String,? extends java.lang.Object>> JSONMapWriter
-
beansWriterASM
public static final JsonWriterI<java.lang.Object> beansWriterASM
Json-Smart V2 Beans serialiser Based on ASM
-
beansWriter
public static final JsonWriterI<java.lang.Object> beansWriter
Json-Smart V1 Beans serialiser
-
arrayWriter
public static final JsonWriterI<java.lang.Object> arrayWriter
Json-Smart ArrayWriterClass
-
toStringWriter
public static final JsonWriterI<java.lang.Object> toStringWriter
ToString Writer
-
-
Method Detail
-
remapField
public <T> void remapField(java.lang.Class<T> type, java.lang.String fromJava, java.lang.String toJson)
remap field name in custom classes- Parameters:
fromJava
- field name in javatoJson
- field name in json- Since:
- 2.1.1
-
getWriterByInterface
public JsonWriterI getWriterByInterface(java.lang.Class<?> clazz)
try to find a Writer by Cheking implemented interface- Parameters:
clazz
- class to serialize- Returns:
- a Writer or null
-
getWrite
public JsonWriterI getWrite(java.lang.Class cls)
-
init
public void init()
-
addInterfaceWriterFirst
public void addInterfaceWriterFirst(java.lang.Class<?> interFace, JsonWriterI<?> writer)
Deprecated.use registerWriterInterfaceFirstassociate an Writer to a interface With Hi priority- Parameters:
interFace
- interface to mapwriter
- writer Object
-
addInterfaceWriterLast
public void addInterfaceWriterLast(java.lang.Class<?> interFace, JsonWriterI<?> writer)
Deprecated.use registerWriterInterfaceLastassociate an Writer to a interface With Low priority- Parameters:
interFace
- interface to mapwriter
- writer Object
-
registerWriterInterfaceLast
public void registerWriterInterfaceLast(java.lang.Class<?> interFace, JsonWriterI<?> writer)
associate an Writer to a interface With Low priority- Parameters:
interFace
- interface to mapwriter
- writer Object
-
registerWriterInterfaceFirst
public void registerWriterInterfaceFirst(java.lang.Class<?> interFace, JsonWriterI<?> writer)
associate an Writer to a interface With Hi priority- Parameters:
interFace
- interface to mapwriter
- writer Object
-
registerWriterInterface
public void registerWriterInterface(java.lang.Class<?> interFace, JsonWriterI<?> writer)
an alias for registerWriterInterfaceLast- Parameters:
interFace
- interface to mapwriter
- writer Object
-
registerWriter
public <T> void registerWriter(JsonWriterI<T> writer, java.lang.Class<?>... cls)
associate an Writer to a Class- Parameters:
writer
-cls
-
-
writeJSONKV
public static void writeJSONKV(java.lang.String key, java.lang.Object value, java.lang.Appendable out, JSONStyle compression) throws java.io.IOException
Write a Key : value entry to a stream- Throws:
java.io.IOException
-
-