public class JSUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JSUtils.JSONSerializer
Extensible class for serializing objects to json.
|
Modifier and Type | Field and Description |
---|---|
static Pattern |
JS_IDENTIFIER
Regex which matches legal javascript identifiers.
|
static Set<String> |
JS_RESERVED
Current and future javascript reserved words.
|
static SimpleDateFormat |
RFC3339_DATE_FORMAT
Formats a date to conform to rfc3339 (like "2000-07-04T07:00:00.000Z").
|
protected static JSUtils.JSONSerializer |
s_jsonSerializer |
Constructor and Description |
---|
JSUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
asciiIdentifier(String s)
Creates an ascii javascript identifier out of the specifed string.
|
static String |
identifier(String s)
Creates a javascript identifier out of the specifed string.
|
static boolean |
jsonProperties(Appendable b,
Map<String,Object> properties,
Collection<String> skip,
Map<String,String> remap)
Creates list of json property name:value pairs.
|
static String |
jsonProperties(Map<String,Object> properties,
Collection<String> skip,
Map<String,String> remap)
Creates list of json property name:value pairs.
|
static void |
jsonProperty(Appendable b,
String name,
Object value)
Creates a json property name:value pair.
|
static String |
jsonProperty(String name,
Object value)
Creates a json property name:value pair.
|
static void |
jsonPropertyName(Appendable b,
Object o)
Writes the specified json property name (ie "foo:" or "'foo bar':").
|
static String |
quote(String s)
Escapes string for printing as a javascript string.
|
public static final Pattern JS_IDENTIFIER
public static SimpleDateFormat RFC3339_DATE_FORMAT
public static final Set<String> JS_RESERVED
protected static JSUtils.JSONSerializer s_jsonSerializer
public static String quote(String s)
public static String identifier(String s)
public static String asciiIdentifier(String s)
public static String jsonProperty(String name, Object value)
public static void jsonProperty(Appendable b, String name, Object value) throws IOException
IOException
public static void jsonPropertyName(Appendable b, Object o) throws IOException
IOException
public static String jsonProperties(Map<String,Object> properties, Collection<String> skip, Map<String,String> remap)
properties
- Properties to output to json.skip
- Property names to skip. May be null.remap
- Property names to remap. May be null.public static boolean jsonProperties(Appendable b, Map<String,Object> properties, Collection<String> skip, Map<String,String> remap) throws IOException
properties
- Properties to output to json.skip
- Property names to skip. May be null.remap
- Property names to remap. May be null.IOException