com.atlassian.jira.util.json
Class JsonUtil

java.lang.Object
  extended by com.atlassian.jira.util.json.JsonUtil

public class JsonUtil
extends Object

JSON related utils. Not in JIRA API, as I didn't want to introduce there dependency on Jackson.

Since:
v5.0

Constructor Summary
JsonUtil()
           
 
Method Summary
static String toJsonString(Object o)
          Util for transforming objects of any type (including arrays, standard primitive wrapper types, beans) into a valid JSON string, which can be directly embedded in <script> section in HTML page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonUtil

public JsonUtil()
Method Detail

toJsonString

public static String toJsonString(@Nullable
                                  Object o)
Util for transforming objects of any type (including arrays, standard primitive wrapper types, beans) into a valid JSON string, which can be directly embedded in <script> section in HTML page. Because parsing of <script> is immediately terminated by web browsers when </ sequence is found (usually </script> marks the end of script section, but browsers are lazy) this method also escapes each "</" into "<\/"

Parameters:
o - object to convert to JSON string, for null you will get "null" string (without qutoes)
Returns:
object converted to its JSON representation


Copyright © 2002-2013 Atlassian. All Rights Reserved.