Package org.ametys.core.util
Class JSONUtils
- java.lang.Object
 - 
- org.ametys.core.util.JSONUtils
 
 
- 
- All Implemented Interfaces:
 Initializable,Component,Serviceable,ThreadSafe
public class JSONUtils extends Object implements Component, ThreadSafe, Serviceable, Initializable
JSON helper 
- 
- 
Constructor Summary
Constructors Constructor Description JSONUtils() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object[]convertJsonToArray(String jsonString)Parse a JSON string to an Object array.List<Object>convertJsonToList(String jsonString)Parse a JSON string to aListobject.Map<String,Object>convertJsonToMap(String jsonString)Parse a JSON string to aMapobjectString[]convertJsonToStringArray(String jsonString)Parse a JSON string to a String array.voidconvertObjectToJson(OutputStream out, Object parameters)Convert an object to JSON string using specified output stream.StringconvertObjectToJson(Object parameters)Convert an object to a JSON stringvoidinitialize()voidservice(ServiceManager manager) 
 - 
 
- 
- 
Constructor Detail
- 
JSONUtils
public JSONUtils()
 
 - 
 
- 
Method Detail
- 
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
 servicein interfaceServiceable- Throws:
 ServiceException
 
- 
initialize
public void initialize() throws Exception
- Specified by:
 initializein interfaceInitializable- Throws:
 Exception
 
- 
convertJsonToMap
public Map<String,Object> convertJsonToMap(String jsonString)
Parse a JSON string to aMapobject- Parameters:
 jsonString- the string to parse- Returns:
 - object the infos as a Map.
 
 
- 
convertJsonToList
public List<Object> convertJsonToList(String jsonString)
Parse a JSON string to aListobject.- Parameters:
 jsonString- the string to parse.- Returns:
 - the infos as a List.
 
 
- 
convertJsonToArray
public Object[] convertJsonToArray(String jsonString)
Parse a JSON string to an Object array.- Parameters:
 jsonString- the JSON string to parse.- Returns:
 - the converted Object array.
 
 
- 
convertJsonToStringArray
public String[] convertJsonToStringArray(String jsonString)
Parse a JSON string to a String array.- Parameters:
 jsonString- the JSON string to parse.- Returns:
 - the converted String array.
 
 
- 
convertObjectToJson
public void convertObjectToJson(OutputStream out, Object parameters)
Convert an object to JSON string using specified output stream.- Parameters:
 out- The output streamparameters- The object to convert
 
- 
convertObjectToJson
public String convertObjectToJson(Object parameters)
Convert an object to a JSON string- Parameters:
 parameters- The object to convert (List, Map ..)- Returns:
 - The JSON string
 
 
 - 
 
 -