Class PojoUtility
- java.lang.Object
-
- org.alfresco.rest.rm.community.util.PojoUtility
-
public class PojoUtility extends Object
Utility class for creating the json object- Since:
- 2.6
- Author:
- Rodica Sutu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>jsonToObject(org.json.JSONArray json, Class<T> classz)Converting json array into a list of java objectsstatic <T> TjsonToObject(org.json.JSONObject json, Class<T> classz)Converting json to java objectstatic StringtoJson(Object model)static StringtoJson(Object model, Class<?> target, Class<?> mixinSource)Converting object to JSON string
-
-
-
Method Detail
-
toJson
public static String toJson(Object model, Class<?> target, Class<?> mixinSource)
Converting object to JSON string- Parameters:
model- The java object model to converttarget- Class (or interface) whose annotations to effectively overridemixinSource- Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary- Returns:
- The converted java object as JSON string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- Throws exceptions if the given object doesn't match to the POJO class model
-
jsonToObject
public static <T> T jsonToObject(org.json.JSONObject json, Class<T> classz)Converting json to java object- Parameters:
json- The json object to convertclassz- Class for the java object- Returns:
- The converted java object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- Throws exceptions if the given object doesn't match to the POJO class model
-
jsonToObject
public static <T> List<T> jsonToObject(org.json.JSONArray json, Class<T> classz)
Converting json array into a list of java objects- Parameters:
json- The json array to convertclassz- Class for the java object- Returns:
- The list of converted java objects
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- Throws exceptions if the given object doesn't match to the POJO class model
-
-