public class JSONWriter extends Writer
Writer
中。Constructor and Description |
---|
JSONWriter(Writer writer,
int indentFactor,
int indent,
JSONConfig config)
构造
|
Modifier and Type | Method and Description |
---|---|
JSONWriter |
beginArray()
JSONArray写出开始,默认写出"["
|
JSONWriter |
beginObj()
JSONObject写出开始,默认写出"{"
|
void |
close() |
JSONWriter |
end()
结束,默认根据开始的类型,补充"}"或"]"
|
void |
flush() |
static JSONWriter |
of(Writer writer,
int indentFactor,
int indent,
JSONConfig config)
创建JSONWriter
|
void |
write(char[] cbuf,
int off,
int len) |
JSONWriter |
writeField(MutablePair<Object,Object> pair,
Filter<MutablePair<Object,Object>> filter)
写出字段名及字段值,如果字段值是
null 且忽略null值,则不写出任何内容 |
JSONWriter |
writeField(String key,
Object value)
Deprecated.
|
JSONWriter |
writeKey(String key)
写出键,自动处理分隔符和缩进,并包装键名
|
JSONWriter |
writeValue(Object value)
|
public JSONWriter(Writer writer, int indentFactor, int indent, JSONConfig config)
writer
- Writer
indentFactor
- 缩进因子,定义每一级别增加的缩进量indent
- 本级别缩进量config
- JSON选项public static JSONWriter of(Writer writer, int indentFactor, int indent, JSONConfig config)
writer
- Writer
indentFactor
- 缩进因子,定义每一级别增加的缩进量indent
- 本级别缩进量config
- JSON选项public JSONWriter beginObj()
public JSONWriter beginArray()
public JSONWriter end()
public JSONWriter writeKey(String key)
key
- 键名public JSONWriter writeValue(Object value)
value
- 值@Deprecated public JSONWriter writeField(String key, Object value)
writeField(MutablePair, Filter)
null
且忽略null值,则不写出任何内容key
- 字段名value
- 字段值public JSONWriter writeField(MutablePair<Object,Object> pair, Filter<MutablePair<Object,Object>> filter)
null
且忽略null值,则不写出任何内容pair
- 键值对filter
- 键值对的过滤器,可以编辑键值对public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
IOException
public void flush()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
Copyright © 2024. All rights reserved.