public class JSONSerializer extends Object
Constructor and Description |
---|
JSONSerializer() |
Modifier and Type | Method and Description |
---|---|
static String |
escape(String s)
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
|
static void |
writeJSONString(Collection list,
Writer out)
Encode a list into JSON text and write it to out.
|
static void |
writeJSONString(Map map,
Writer out)
Encode a map into JSON text and write it to out.
|
static void |
writeJSONString(Object[] array,
Writer out) |
static void |
writeJSONString(Object value,
Writer out)
Encode an object into JSON text and write it to out.
|
public static void writeJSONString(Object value, Writer out) throws IOException
If this object is a Map or a List, and it's also a JSONStreamAware or a JSONAware, JSONStreamAware or JSONAware will be considered firstly.
DO NOT call this method from writeJSONString(Writer) of a class that implements both JSONStreamAware and (Map or List) with "this" as the first parameter, use JSONObject.writeJSONString(Map, Writer) or JSONArray.writeJSONString(List, Writer) instead.
value
- writer
- IOException
JSONObject.writeJSONString(Map, Writer)
,
JSONArray.writeJSONString(List, Writer)
public static void writeJSONString(Map map, Writer out) throws IOException
map
- out
- IOException
JSONValue.writeJSONString(Object, Writer)
public static void writeJSONString(Object[] array, Writer out) throws IOException
IOException
public static void writeJSONString(Collection list, Writer out) throws IOException
list
- out
- IOException
JSONValue.writeJSONString(Object, Writer)
Copyright © 2012-2018. All Rights Reserved.