Package org.ametys.core.util
Class JSONUtils
java.lang.Object
org.ametys.core.util.JSONUtils
- All Implemented Interfaces:
Initializable,Component,Serviceable,ThreadSafe
JSON helper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]convertJsonToArray(String jsonString) Parse a JSON string to an Object array.convertJsonToList(String jsonString) Parse a JSON string to aListobject.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.convertObjectToJson(Object parameters) Convert an object to a JSON stringvoidvoidservice(ServiceManager manager)
-
Field Details
-
ROLE
The avalon role
-
-
Constructor Details
-
JSONUtils
public JSONUtils()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
convertJsonToMap
Parse a JSON string to aMapobject- Parameters:
jsonString- the string to parse- Returns:
- object the infos as a Map.
-
convertJsonToList
Parse a JSON string to aListobject.- Parameters:
jsonString- the string to parse.- Returns:
- the infos as a List.
-
convertJsonToArray
Parse a JSON string to an Object array.- Parameters:
jsonString- the JSON string to parse.- Returns:
- the converted Object array.
-
convertJsonToStringArray
Parse a JSON string to a String array.- Parameters:
jsonString- the JSON string to parse.- Returns:
- the converted String array.
-
convertObjectToJson
Convert an object to JSON string using specified output stream.- Parameters:
out- The output streamparameters- The object to convert
-
convertObjectToJson
Convert an object to a JSON string- Parameters:
parameters- The object to convert (List, Map ..)- Returns:
- The JSON string
-