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 aList
object.Map<String,Object>
convertJsonToMap(String jsonString)
Parse a JSON string to aMap
objectString[]
convertJsonToStringArray(String jsonString)
Parse a JSON string to a String array.void
convertObjectToJson(OutputStream out, Object parameters)
Convert an object to JSON string using specified output stream.String
convertObjectToJson(Object parameters)
Convert an object to a JSON stringvoid
initialize()
void
service(ServiceManager manager)
-
-
-
Constructor Detail
-
JSONUtils
public JSONUtils()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
convertJsonToMap
public Map<String,Object> convertJsonToMap(String jsonString)
Parse a JSON string to aMap
object- 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 aList
object.- 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
-
-