- java.lang.Object
-
- aeonics.util.Json
-
public class Json extends java.lang.Object
Fault tolerant JSON encoder/decoder
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Data
decode(java.lang.String json)
Decodes the input json into a data structurestatic java.lang.String
encode(Data data)
Encodes the specified object in JSON.static java.lang.String
encode(Exportable exportable)
Encodes the specified object in JSON.static java.lang.String
encode(java.lang.Object object)
Encodes the specified object in JSON.static java.lang.String
escape(java.lang.String s)
Escapes special characters for JSON outputstatic java.lang.String
unescape(java.lang.String s)
Unescapes special characters from encoded JSON input
-
-
-
Method Detail
-
encode
public static java.lang.String encode(java.lang.Object object)
Encodes the specified object in JSON. The object is first wrapped in a data structure then convertedtoString()
.- Parameters:
object
- the object to convert to JSON- Returns:
- a JSON string representation of the object
- See Also:
Data
-
encode
public static java.lang.String encode(Exportable exportable)
Encodes the specified object in JSON. The object is firstExportable.export()
then convertedtoString()
.- Parameters:
exportable
- the object to convert to JSON- Returns:
- a JSON string representation of the object
-
encode
public static java.lang.String encode(Data data)
Encodes the specified object in JSON. The object convertedtoString()
.- Parameters:
data
- the object to convert to JSON- Returns:
- a JSON string representation of the object
-
escape
public static java.lang.String escape(java.lang.String s)
Escapes special characters for JSON output- Parameters:
s
- the text to escape- Returns:
- the escaped text
-
unescape
public static java.lang.String unescape(java.lang.String s)
Unescapes special characters from encoded JSON input- Parameters:
s
- the text to unescape- Returns:
- the unescaped text
-
decode
public static Data decode(java.lang.String json)
Decodes the input json into a data structure- Parameters:
json
- the input text- Returns:
- the parsed data
-
-