public class JSON2Map
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
bufferSize |
static int |
JSON_ARRAY |
static int |
JSON_BOOLEAN |
static int |
JSON_MAP |
static int |
JSON_NULL |
static int |
JSON_NUMBER |
static int |
JSON_STRING |
static int |
JSON_UNKNOWN |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsKey(java.util.List pl,
java.lang.String keyPath)
returns true if the keyPath exists or false otherwise
|
static boolean |
containsKey(java.util.Map ph,
java.lang.String keyPath)
returns true if the keyPath exists or false otherwise
|
static int |
count(java.util.List pl,
java.lang.String keyPath)
returns the number of children referenced by the keyPath or -1
|
static int |
count(java.util.Map ph,
java.lang.String keyPath)
returns the number of children referenced by the keyPath or -1
|
static java.lang.String |
diff(java.util.List ps,
java.util.List pt,
java.lang.String indent)
It returns the difference in JSON between two Lists
|
static java.lang.String |
diff(java.util.Map ps,
java.util.Map pt,
java.lang.String indent)
It returns the difference in JSON between two Maps
|
static int |
escape(char[] buffer,
int offset,
int length)
returns the position of the first escaped char or -1 if not found
|
static int |
evaluateIndex(java.lang.String expr,
java.util.List list)
returns the evaluated index of the list or -1 on failure or no hit
|
static void |
flatten(java.util.Map m)
It converts a multi-layered map into a flat map with the leaves only.
|
static void |
flatten(java.lang.String s,
java.util.Map m) |
static java.lang.String |
format(java.util.List pl,
Template temp)
returns the formatted JSON text for the given template or null
|
static java.lang.String |
format(java.util.Map ph,
Template temp)
returns the formatted JSON text for the given template or null
|
static java.lang.Object |
get(java.util.List pl,
java.lang.String keyPath)
returns the raw object referenced by the keyPath or null
|
static java.lang.Object |
get(java.util.Map ph,
java.lang.String keyPath)
returns the raw object referenced by the keyPath or null
|
static int |
getDataType(java.util.List pl,
java.lang.String keyPath) |
static int |
getDataType(java.util.Map ph,
java.lang.String keyPath) |
static java.lang.Object |
getParent(java.util.List pl,
java.lang.String keyPath)
returns the parent of the object referenced by the keyPath or null
|
static java.lang.Object |
getParent(java.util.Map ph,
java.lang.String keyPath)
returns the parent of the object referenced by the keyPath or null
|
static boolean |
isArray(java.lang.String text) |
static boolean |
isHash(java.lang.String text) |
static int |
locate(int id,
java.lang.String text) |
static int |
locate(int id,
java.lang.String text,
int fromIndex)
locates the end position of the first JSON object on the id-th level
from the starting point of fromIndex and returns the position or -1 upon
failure.
|
static int |
look(char[] buffer,
int offset,
int length)
returns the position of the first end chars or -1 if not found
|
static void |
main(java.lang.String[] args) |
static int |
next(char[] buffer,
int offset,
int length)
returns the position of the first comment char or -1 if not found
|
static java.lang.String |
normalize(java.util.List a)
returns JSON content for a given List in alphabetical ascending order
|
static java.lang.String |
normalize(java.util.List a,
java.lang.String indent,
java.lang.String end)
It returns JSON content for a given List in alphabetical ascending order
|
static java.lang.String |
normalize(java.util.Map m)
returns JSON content for a given Map in alphabetical ascending order
|
static java.lang.String |
normalize(java.util.Map m,
java.lang.String indent,
java.lang.String end)
It returns JSON content for a given Map in alphabatical ascending order
|
static java.lang.Object |
parse(java.io.Reader in)
parses JSON stream from in and returns either a Map or a List with
unescaped JSON data.
|
static java.lang.Object |
parseJSON(java.io.Reader in,
boolean withOrder)
parses JSON stream from in and returns either a Map or a List with
unescaped JSON data as well as the key list with orginal order for maps.
|
static java.lang.Object |
put(java.util.List pl,
java.lang.String keyPath,
java.lang.Object data)
puts raw data and returns the replaced object referenced by the keyPath
|
static java.lang.Object |
put(java.util.Map ph,
java.lang.String keyPath,
java.lang.Object data)
puts raw data and returns the replaced object referenced by the keyPath
|
static java.lang.Object |
remove(java.util.List pl,
java.lang.String keyPath)
returns the removed object referenced by the keyPath or null
|
static java.lang.Object |
remove(java.util.Map ph,
java.lang.String keyPath)
returns the removed object referenced by the keyPath or null
|
static int |
scan(char[] buffer,
int offset,
int length,
char target)
returns the position of the first target or -1 if not found
|
static int |
skip(char[] buffer,
int offset,
int length)
returns the position of the first non-space char or -1 if not found
|
static java.lang.String |
toJSON(java.util.List a,
java.lang.String indent,
java.lang.String end)
It returns JSON content for a given List with indent
|
protected static java.lang.String |
toJSON(java.util.List a,
java.lang.String indent,
java.lang.String end,
boolean withOrder)
It returns JSON content for a given List with indent and ordering support
|
static java.lang.String |
toJSON(java.util.Map m)
It returns JSON content in the tabular format for a given Map
|
protected static java.lang.String |
toJSON(java.util.Map m,
boolean withOrder)
It returns JSON content for a given Map with ordering support
|
static java.lang.String |
toJSON(java.util.Map m,
java.lang.String indent,
java.lang.String end)
It returns JSON content for a given Map with indent
|
protected static java.lang.String |
toJSON(java.util.Map m,
java.lang.String indent,
java.lang.String end,
boolean withOrder)
It returns JSON content for a given Map with indent and ordering support
|
static java.lang.String |
toXML(java.util.Map m)
It returns XML content in the tabular format for a given Map
|
static java.lang.String |
toXML(java.util.Map m,
java.lang.String indent,
java.lang.String end)
It returns XML content for a given Map with indent
|
static java.lang.String |
toXML(java.lang.String key,
java.util.List a,
java.lang.String indent,
java.lang.String end)
It returns XML content for a given List with indent
|
static java.lang.String |
trim(java.lang.StringBuffer strBuf)
trims off white space chars on both ends and returns the string
|
static void |
unflatten(java.util.Map m)
It unflattens a flat map into a multi-layered map.
|
static void |
unflatten(java.lang.String s,
java.util.Map m) |
public static final int bufferSize
public static final int JSON_UNKNOWN
public static final int JSON_NULL
public static final int JSON_STRING
public static final int JSON_NUMBER
public static final int JSON_BOOLEAN
public static final int JSON_ARRAY
public static final int JSON_MAP
public static java.lang.String toJSON(java.util.Map m)
protected static java.lang.String toJSON(java.util.Map m, boolean withOrder)
public static java.lang.String toJSON(java.util.Map m, java.lang.String indent, java.lang.String end)
protected static java.lang.String toJSON(java.util.Map m, java.lang.String indent, java.lang.String end, boolean withOrder)
public static java.lang.String toJSON(java.util.List a, java.lang.String indent, java.lang.String end)
protected static java.lang.String toJSON(java.util.List a, java.lang.String indent, java.lang.String end, boolean withOrder)
public static java.lang.String normalize(java.util.Map m)
public static java.lang.String normalize(java.util.Map m, java.lang.String indent, java.lang.String end)
public static java.lang.String normalize(java.util.List a)
public static java.lang.String normalize(java.util.List a, java.lang.String indent, java.lang.String end)
public static java.lang.String diff(java.util.Map ps, java.util.Map pt, java.lang.String indent)
public static java.lang.String diff(java.util.List ps, java.util.List pt, java.lang.String indent)
public static void flatten(java.util.Map m)
public static void flatten(java.lang.String s, java.util.Map m)
public static void unflatten(java.util.Map m)
public static void unflatten(java.lang.String s, java.util.Map m)
public static java.lang.String toXML(java.util.Map m)
public static java.lang.String toXML(java.util.Map m, java.lang.String indent, java.lang.String end)
public static java.lang.String toXML(java.lang.String key, java.util.List a, java.lang.String indent, java.lang.String end)
public static boolean containsKey(java.util.Map ph, java.lang.String keyPath)
public static boolean containsKey(java.util.List pl, java.lang.String keyPath)
public static int count(java.util.Map ph, java.lang.String keyPath)
public static int count(java.util.List pl, java.lang.String keyPath)
public static java.lang.Object remove(java.util.Map ph, java.lang.String keyPath)
public static java.lang.Object remove(java.util.List pl, java.lang.String keyPath)
public static java.lang.Object getParent(java.util.Map ph, java.lang.String keyPath)
public static java.lang.Object getParent(java.util.List pl, java.lang.String keyPath)
public static java.lang.Object get(java.util.Map ph, java.lang.String keyPath)
public static java.lang.Object get(java.util.List pl, java.lang.String keyPath)
public static int getDataType(java.util.Map ph, java.lang.String keyPath)
public static int getDataType(java.util.List pl, java.lang.String keyPath)
public static java.lang.Object put(java.util.Map ph, java.lang.String keyPath, java.lang.Object data)
public static java.lang.Object put(java.util.List pl, java.lang.String keyPath, java.lang.Object data)
public static java.lang.String format(java.util.Map ph, Template temp)
public static java.lang.String format(java.util.List pl, Template temp)
public static int evaluateIndex(java.lang.String expr, java.util.List list)
public static java.lang.Object parse(java.io.Reader in) throws java.io.IOException
java.io.IOException
public static java.lang.Object parseJSON(java.io.Reader in, boolean withOrder) throws java.io.IOException
java.io.IOException
public static int scan(char[] buffer, int offset, int length, char target)
public static int next(char[] buffer, int offset, int length)
public static int escape(char[] buffer, int offset, int length)
public static int look(char[] buffer, int offset, int length)
public static int skip(char[] buffer, int offset, int length)
public static java.lang.String trim(java.lang.StringBuffer strBuf)
public static boolean isHash(java.lang.String text)
public static boolean isArray(java.lang.String text)
public static int locate(int id, java.lang.String text)
public static int locate(int id, java.lang.String text, int fromIndex)
public static void main(java.lang.String[] args)