public class JsonUtil extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
JsonUtil.Context
分析过程环境
|
static interface |
JsonUtil.Listener
监听分析事件
|
static interface |
JsonUtil.NodeBuilder
节点构建器
|
static interface |
JsonUtil.NodeBuilderExt
节点构建器
|
static interface |
JsonUtil.ParseHook
JSON解析过程钩子
|
protected static class |
JsonUtil.WrapListener |
protected static class |
JsonUtil.WrapNodeBuilder |
| 限定符和类型 | 字段和说明 |
|---|---|
protected static int[] |
_Multiply
10^n(n=0~10)表
|
protected static StringBuilderPool |
_NameBuilderPool
名称缓冲池
|
static StringPool |
_NamePool
名称池
|
static cn.weforward.common.json.JsonUtil.NopObject |
_NopObject |
protected static JsonUtil.NodeBuilderExt |
DEFAULT_BUILDER |
protected static JsonUtil.ParseHook |
NOP_HOOK |
protected static JsonUtil.Listener |
UNASSIGNED_LISTENER
不指定监听器时
|
| 构造器和说明 |
|---|
JsonUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Appendable |
addNonZero(Appendable out,
String key,
long value) |
static Appendable |
addNotNull(Appendable out,
String key,
Object value) |
static boolean |
equalsLowerCase(CharSequence lowerStr,
CharSequence str)
按小写比较
|
static void |
escape(CharSequence string,
Appendable appender)
编码JOSN字串
any-Unicode-character-except-"-or-\-or- control-character
\" \\ \/ \b \f \n \r \t \ u four-hex-digits
char = unescaped /
escape (
%x22 / ; " quotation mark U+0022
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
%x66 / ; f form feed U+000C
%x6E / ; n line feed U+000A
%x72 / ; r carriage return U+000D
%x74 / ; t tab U+0009
%x75 4HEXDIG ) ; uXXXX U+XXXX
escape = %x5C ; \
quotation-mark = %x22 ; "
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
|
static void |
format(JsonNode json,
JsonOutput out) |
protected static void |
formatArray(JsonArray array,
Appendable out) |
protected static void |
formatObject(JsonObject object,
Appendable out) |
static Appendable |
formatValue(Object value,
Appendable out) |
static boolean |
isBlank(char ch)
是否空白字符(空格、TAB、换行符等)
|
static JsonNode |
parse(JsonInput in)
由JSON格式流解析为JsonNode
|
static JsonNode |
parse(JsonInput in,
JsonUtil.Listener listener)
由JSON格式流解析为JsonNode
|
static JsonNode |
parse(JsonInput in,
JsonUtil.Listener listener,
JsonUtil.NodeBuilder builder)
由JSON格式流解析为JsonNode
|
static JsonNode |
parse(JsonInput in,
JsonUtil.NodeBuilderExt builder,
JsonUtil.ParseHook hook)
由JSON格式流解析为JsonNode
|
static JsonNode |
parse(JsonInput in,
JsonUtil.ParseHook hook)
由JSON格式流解析为JsonNode
|
protected static JsonArray |
parseArray(JsonUtil.Context ctx,
JsonUtil.NodeBuilderExt builder,
String name,
JsonNode parent)
解析Json数组
|
protected static JsonObject |
parseObject(JsonUtil.Context ctx,
JsonUtil.NodeBuilderExt builder,
String name,
JsonNode parent)
解析Json对象
|
protected static Object |
parseValue(JsonUtil.Context ctx,
JsonUtil.NodeBuilderExt builder,
String name,
JsonNode parent,
int begin)
解析Json节点值
|
static void |
rtrim(StringBuilder builder)
去除后部空格
|
static char |
skipBlank(JsonInput in,
int limit)
跳过空格、换行符等
|
static Appendable |
unescape(JsonInput in,
Appendable builder) |
public static StringPool _NamePool
protected static StringBuilderPool _NameBuilderPool
protected static final int[] _Multiply
protected static JsonUtil.ParseHook NOP_HOOK
protected static JsonUtil.NodeBuilderExt DEFAULT_BUILDER
public static cn.weforward.common.json.JsonUtil.NopObject _NopObject
protected static JsonUtil.Listener UNASSIGNED_LISTENER
public static JsonNode parse(JsonInput in) throws IOException
in - 格式流IOException - IO异常时抛出public static JsonNode parse(JsonInput in, JsonUtil.Listener listener) throws IOException
in - 格式流listener - 可选的监听器(可以为null)IOException - IO异常时抛出public static JsonNode parse(JsonInput in, JsonUtil.ParseHook hook) throws IOException
in - 格式流hook - 可选的过程钩子(可以为null)IOException - IO异常时抛出public static JsonNode parse(JsonInput in, JsonUtil.Listener listener, JsonUtil.NodeBuilder builder) throws IOException
in - 格式流listener - 可选的监听器(可以为null)builder - 节点构建器IOException - IO异常时抛出public static JsonNode parse(JsonInput in, JsonUtil.NodeBuilderExt builder, JsonUtil.ParseHook hook) throws IOException
in - 格式流builder - 节点构建器hook - 可选的过程钩子(可以为null)IOException - IO异常时抛出protected static Object parseValue(JsonUtil.Context ctx, JsonUtil.NodeBuilderExt builder, String name, JsonNode parent, int begin) throws IOException
ctx - 分析过程环境builder - 节点构建器name - 节点名(可能null)parent - 父节点(可能null)begin - 开始位置IOException - IO异常时抛出protected static JsonObject parseObject(JsonUtil.Context ctx, JsonUtil.NodeBuilderExt builder, String name, JsonNode parent) throws IOException
ctx - 分析过程环境builder - 节点构建器name - 节点名(可能null)parent - 父节点(可能null)IOException - IO异常时抛出protected static JsonArray parseArray(JsonUtil.Context ctx, JsonUtil.NodeBuilderExt builder, String name, JsonNode parent) throws IOException
ctx - 分析过程环境builder - 节点构建器name - 节点名(可能null)parent - 父节点(可能null)IOException - IO异常时抛出public static void format(JsonNode json, JsonOutput out) throws IOException
IOExceptionprotected static void formatObject(JsonObject object, Appendable out) throws IOException
IOExceptionprotected static void formatArray(JsonArray array, Appendable out) throws IOException
IOExceptionpublic static Appendable formatValue(Object value, Appendable out) throws IOException
IOExceptionpublic static boolean equalsLowerCase(CharSequence lowerStr, CharSequence str)
lowerStr - 小字的要比较字串str - 不分大小写的被比较字串public static void rtrim(StringBuilder builder)
builder - 要去除后空格的字串public static char skipBlank(JsonInput in, int limit) throws IOException
in - JSON格式流limit - 限制跳过的字符数IOException - IO异常时抛出public static final boolean isBlank(char ch)
ch - 要检查的字符public static void escape(CharSequence string, Appendable appender) throws IOException
string - 要转义的字串appender - 转义后输出的序列器IOException - IO异常时抛出public static Appendable unescape(JsonInput in, Appendable builder) throws IOException
IOExceptionpublic static Appendable addNotNull(Appendable out, String key, Object value) throws IOException
IOExceptionpublic static Appendable addNonZero(Appendable out, String key, long value) throws IOException
IOExceptionCopyright © 2022. All rights reserved.