public class JSONUtils extends Object implements Component, ThreadSafe, Serviceable, Initializable
Modifier and Type | Field and Description |
---|---|
private HelpSerializer |
_helpSerializer |
private I18nizableTextSerializer |
_i18nizableTextSerializer |
private JsonFactory |
_jsonFactory |
private LocalDateSerializer |
_localDateSerializer |
private ObjectMapper |
_objectMapper |
private ZonedDateTimeSerializer |
_zoneDateTimeSerializer |
static String |
ROLE
The avalon role
|
Constructor and Description |
---|
JSONUtils() |
Modifier and Type | Method and Description |
---|---|
Object[] |
convertJsonToArray(String jsonString)
Parse a JSON string to an Object array.
|
List<Object> |
convertJsonToList(String jsonString)
Parse a JSON string to a
List object. |
Map<String,Object> |
convertJsonToMap(String jsonString)
Parse a JSON string to a
Map object |
String[] |
convertJsonToStringArray(String jsonString)
Parse a JSON string to a String array.
|
String |
convertObjectToJson(Object parameters)
Convert an object to a JSON string
|
void |
convertObjectToJson(OutputStream out,
Object parameters)
Convert an object to JSON string using specified output stream.
|
void |
initialize() |
void |
service(ServiceManager manager) |
private JsonFactory _jsonFactory
private ObjectMapper _objectMapper
private I18nizableTextSerializer _i18nizableTextSerializer
private HelpSerializer _helpSerializer
private ZonedDateTimeSerializer _zoneDateTimeSerializer
private LocalDateSerializer _localDateSerializer
public JSONUtils()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize() throws Exception
initialize
in interface Initializable
Exception
public Map<String,Object> convertJsonToMap(String jsonString)
Map
objectjsonString
- the string to parsepublic List<Object> convertJsonToList(String jsonString)
List
object.jsonString
- the string to parse.public Object[] convertJsonToArray(String jsonString)
jsonString
- the JSON string to parse.public String[] convertJsonToStringArray(String jsonString)
jsonString
- the JSON string to parse.public void convertObjectToJson(OutputStream out, Object parameters)
out
- The output streamparameters
- The object to convertpublic String convertObjectToJson(Object parameters)
parameters
- The object to convert (List, Map ..)