Package fr.paris.lutece.util.json
Class JsonUtil
java.lang.Object
fr.paris.lutece.util.json.JsonUtil
JsonUtil
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildJsonResponse(AbstractJsonResponse jsonResponse) return a string containing the JSON flowstatic <T> Tdeserialize(String requestBody, Class<T> targetType) Deserialize a JSON string into an object of the specified type.static StringSerialize an object to a JSON string.
-
Field Details
-
CONTENT_TYPE_JSON
- See Also:
-
-
Method Details
-
buildJsonResponse
return a string containing the JSON flow- Parameters:
jsonResponse- the JSON Response Object- Returns:
- return a string containing the JSON flow
-
deserialize
public static <T> T deserialize(String requestBody, Class<T> targetType) throws com.fasterxml.jackson.core.JsonProcessingException Deserialize a JSON string into an object of the specified type.- Type Parameters:
T- the type of the object- Parameters:
requestBody- the JSON string to deserializetargetType- the class of the object to deserialize into- Returns:
- the deserialized object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if there is an error during deserialization
-
serialize
public static String serialize(Object objectValue) throws com.fasterxml.jackson.core.JsonProcessingException Serialize an object to a JSON string.- Parameters:
objectValue-- Returns:
- a JSON string representation of the object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-