Package org.javlo.module.file
Class JSONSerializer
- java.lang.Object
 - 
- org.javlo.module.file.JSONSerializer
 
 
- 
public class JSONSerializer extends Object
- Author:
 - FangYidong
 
 
- 
- 
Constructor Summary
Constructors Constructor Description JSONSerializer() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringescape(String s)Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).static voidwriteJSONString(Object[] array, Writer out)static voidwriteJSONString(Object value, Writer out)Encode an object into JSON text and write it to out.static voidwriteJSONString(Collection list, Writer out)Encode a list into JSON text and write it to out.static voidwriteJSONString(Map map, Writer out)Encode a map into JSON text and write it to out. 
 - 
 
- 
- 
Method Detail
- 
writeJSONString
public static void writeJSONString(Object value, Writer out) throws IOException
Encode an object into JSON text and write it to out.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.
- Parameters:
 value-writer-- Throws:
 IOException- See Also:
 JSONObject.writeJSONString(Map, Writer),JSONArray.writeJSONString(List, Writer)
 
- 
writeJSONString
public static void writeJSONString(Map map, Writer out) throws IOException
Encode a map into JSON text and write it to out. If this map is also a JSONAware or JSONStreamAware, JSONAware or JSONStreamAware specific behaviours will be ignored at this top level.- Parameters:
 map-out-- Throws:
 IOException- See Also:
 JSONValue.writeJSONString(Object, Writer)
 
- 
writeJSONString
public static void writeJSONString(Object[] array, Writer out) throws IOException
- Throws:
 IOException
 
- 
writeJSONString
public static void writeJSONString(Collection list, Writer out) throws IOException
Encode a list into JSON text and write it to out. If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level.- Parameters:
 list-out-- Throws:
 IOException- See Also:
 JSONValue.writeJSONString(Object, Writer)
 
 - 
 
 -