com.alibaba.dubbo.common.json
Class JSON

java.lang.Object
  extended by com.alibaba.dubbo.common.json.JSON

public class JSON
extends Object

JSON.

Author:
qian.lei

Field Summary
static byte ARRAY_ITEM
           
static char COLON
           
static char COMMA
           
static byte END
           
static char LBRACE
           
static char LSQUARE
           
static String NULL
           
static byte OBJECT_ITEM
           
static byte OBJECT_VALUE
           
static char QUOTE
           
static char RBRACE
           
static char RSQUARE
           
static byte START
           
 
Method Summary
static String json(Object obj)
          json string.
static String json(Object obj, String[] properties)
          json string.
static void json(Object obj, String[] properties, Writer writer)
           
static void json(Object obj, String[] properties, Writer writer, boolean writeClass)
          write json.
static void json(Object obj, Writer writer)
          write json.
static void json(Object obj, Writer writer, boolean writeClass)
           
static Object parse(Reader reader)
          parse json.
static Object[] parse(Reader reader, Class<?>[] types)
          parse json.
static
<T> T
parse(Reader reader, Class<T> type)
          parse json
static Object parse(Reader reader, JSONVisitor handler)
          parse json.
static Object parse(String json)
          parse json.
static Object[] parse(String json, Class<?>[] types)
          parse json.
static
<T> T
parse(String json, Class<T> type)
          parse json.
static Object parse(String json, JSONVisitor handler)
          parse json.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LBRACE

public static final char LBRACE
See Also:
Constant Field Values

RBRACE

public static final char RBRACE
See Also:
Constant Field Values

LSQUARE

public static final char LSQUARE
See Also:
Constant Field Values

RSQUARE

public static final char RSQUARE
See Also:
Constant Field Values

COMMA

public static final char COMMA
See Also:
Constant Field Values

COLON

public static final char COLON
See Also:
Constant Field Values

QUOTE

public static final char QUOTE
See Also:
Constant Field Values

NULL

public static final String NULL
See Also:
Constant Field Values

END

public static final byte END
See Also:
Constant Field Values

START

public static final byte START
See Also:
Constant Field Values

OBJECT_ITEM

public static final byte OBJECT_ITEM
See Also:
Constant Field Values

OBJECT_VALUE

public static final byte OBJECT_VALUE
See Also:
Constant Field Values

ARRAY_ITEM

public static final byte ARRAY_ITEM
See Also:
Constant Field Values
Method Detail

json

public static String json(Object obj)
                   throws IOException
json string.

Parameters:
obj - object.
Returns:
json string.
Throws:
IOException.
IOException

json

public static void json(Object obj,
                        Writer writer)
                 throws IOException
write json.

Parameters:
obj - object.
writer - writer.
Throws:
IOException.
IOException

json

public static void json(Object obj,
                        Writer writer,
                        boolean writeClass)
                 throws IOException
Throws:
IOException

json

public static String json(Object obj,
                          String[] properties)
                   throws IOException
json string.

Parameters:
obj - object.
properties - property name array.
Returns:
json string.
Throws:
IOException.
IOException

json

public static void json(Object obj,
                        String[] properties,
                        Writer writer)
                 throws IOException
Throws:
IOException

json

public static void json(Object obj,
                        String[] properties,
                        Writer writer,
                        boolean writeClass)
                 throws IOException
write json.

Parameters:
obj - object.
properties - property name array.
writer - writer.
Throws:
IOException.
IOException

parse

public static Object parse(String json)
                    throws ParseException
parse json.

Parameters:
json - json source.
Returns:
JSONObject or JSONArray or Boolean or Long or Double or String or null
Throws:
ParseException

parse

public static Object parse(Reader reader)
                    throws IOException,
                           ParseException
parse json.

Parameters:
reader - reader.
Returns:
JSONObject or JSONArray or Boolean or Long or Double or String or null
Throws:
IOException
ParseException

parse

public static <T> T parse(String json,
                          Class<T> type)
               throws ParseException
parse json.

Parameters:
json - json string.
type - target type.
Returns:
result.
Throws:
ParseException

parse

public static <T> T parse(Reader reader,
                          Class<T> type)
               throws IOException,
                      ParseException
parse json

Parameters:
reader - json source.
type - target type.
Returns:
result.
Throws:
IOException
ParseException

parse

public static Object[] parse(String json,
                             Class<?>[] types)
                      throws ParseException
parse json.

Parameters:
json - json string.
types - target type array.
Returns:
result.
Throws:
ParseException

parse

public static Object[] parse(Reader reader,
                             Class<?>[] types)
                      throws IOException,
                             ParseException
parse json.

Parameters:
reader - json source.
types - target type array.
Returns:
result.
Throws:
IOException
ParseException

parse

public static Object parse(String json,
                           JSONVisitor handler)
                    throws ParseException
parse json.

Parameters:
json - json string.
handler - handler.
Returns:
result.
Throws:
ParseException

parse

public static Object parse(Reader reader,
                           JSONVisitor handler)
                    throws IOException,
                           ParseException
parse json.

Parameters:
reader - json source.
handler - handler.
Returns:
resule.
Throws:
IOException
ParseException


Copyright © 2012–2017 Alibaba. All rights reserved.