Package net.sf.json.util
Class WebUtils
- java.lang.Object
-
- net.sf.json.util.WebUtils
-
public class WebUtils extends java.lang.ObjectProvides useful methods for working with JSON and web.
-
-
Field Summary
Fields Modifier and Type Field Description private static WebHijackPreventionStrategyDEFAULT_WEB_HIJACK_PREVENTION_STRATEGYprivate static WebHijackPreventionStrategywebHijackPreventionStrategy
-
Constructor Summary
Constructors Modifier Constructor Description privateWebUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static WebHijackPreventionStrategygetWebHijackPreventionStrategy()Returns the configured WebHijackPreventionStrategy.private static java.lang.Stringjoin(JSONArray jsonArray)static java.lang.Stringprotect(JSON json)Transforms the input Json string using the configured WebHijackPreventionStrategy.static java.lang.Stringprotect(JSON json, boolean shrink)Transforms the input Json string using the configured WebHijackPreventionStrategy.private static java.lang.Stringquote(java.lang.String str)static voidsetWebHijackPreventionStrategy(WebHijackPreventionStrategy strategy)Sets a WebHijackPreventionStrategy.
Will use default value (WebHijackPreventionStrategy.INFINITE_LOOP) if null.private static java.lang.StringtoString(java.lang.Object object)static java.lang.StringtoString(JSON json)Returns a string represenation of a JSON value.
When an object property name does not contain a space (' ') or a colon (':'), the quotes are omitted.private static java.lang.StringtoString(JSONArray jsonArray)private static java.lang.StringtoString(JSONNull jsonNull)private static java.lang.StringtoString(JSONObject jsonObject)
-
-
-
Field Detail
-
DEFAULT_WEB_HIJACK_PREVENTION_STRATEGY
private static final WebHijackPreventionStrategy DEFAULT_WEB_HIJACK_PREVENTION_STRATEGY
-
webHijackPreventionStrategy
private static WebHijackPreventionStrategy webHijackPreventionStrategy
-
-
Method Detail
-
getWebHijackPreventionStrategy
public static WebHijackPreventionStrategy getWebHijackPreventionStrategy()
Returns the configured WebHijackPreventionStrategy.
-
protect
public static java.lang.String protect(JSON json)
Transforms the input Json string using the configured WebHijackPreventionStrategy.- Parameters:
json- the input string- Returns:
- String a transformed json string
-
protect
public static java.lang.String protect(JSON json, boolean shrink)
Transforms the input Json string using the configured WebHijackPreventionStrategy.- Parameters:
json- the input stringshrink- if redundant key quotes may be eliminated.- Returns:
- String a transformed json string
-
setWebHijackPreventionStrategy
public static void setWebHijackPreventionStrategy(WebHijackPreventionStrategy strategy)
Sets a WebHijackPreventionStrategy.
Will use default value (WebHijackPreventionStrategy.INFINITE_LOOP) if null.
-
toString
public static java.lang.String toString(JSON json)
Returns a string represenation of a JSON value.
When an object property name does not contain a space (' ') or a colon (':'), the quotes are omitted. This is done to reduce the amount of bytes sent to a web browser.
USE WITH CAUTION.
-
join
private static java.lang.String join(JSONArray jsonArray)
-
quote
private static java.lang.String quote(java.lang.String str)
-
toString
private static java.lang.String toString(JSONArray jsonArray)
-
toString
private static java.lang.String toString(JSONNull jsonNull)
-
toString
private static java.lang.String toString(JSONObject jsonObject)
-
toString
private static java.lang.String toString(java.lang.Object object)
-
-