public class JSON extends Object
| Constructor and Description |
|---|
JSON() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
parse(String s)
Parses a JSON string and returns a corresponding Java object.
|
static Object |
parse(String s,
BSONCallback c)
Parses a JSON string and constructs a corresponding Java object by calling
the methods of a
BSONCallback during parsing. |
static String |
serialize(Object o)
Serializes an object into its JSON form.
|
static void |
serialize(Object o,
StringBuilder buf)
Serializes an object into its JSON form.
|
public static String serialize(Object o)
This method delegates serialization to JSONSerializers.getLegacy
o - object to serializeJSONSerializers.getLegacy()public static void serialize(Object o, StringBuilder buf)
This method delegates serialization to JSONSerializers.getLegacy
o - object to serializebuf - StringBuilder containing the JSON representation under constructionJSONSerializers.getLegacy()public static Object parse(String s)
DBObject
(if the string is a JSON object or array), or a boxed primitive
value according to the following mapping:
java.lang.Boolean for true or false
java.lang.Integer for integers between
Integer.MIN_VALUE and Integer.MAX_VALUE
java.lang.Long for integers outside of this range
java.lang.Double for floating point numbers
If the parameter is a string that contains a single-quoted
or double-quoted string, it is returned as an unquoted
java.lang.String.
s - the string to parseJSONParseException - if s is not valid JSONpublic static Object parse(String s, BSONCallback c)
BSONCallback during parsing.
If the callback c is null, this method is equivalent to
parse(String).s - the string to parsec - the BSONCallback to call during parsingJSONParseException - if s is not valid JSON