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 Details

    • toJson

      public static String toJson(Object model)
    • toJson

      public static String toJson(Object model, Class<?> target, Class<?> mixinSource)
      Converting object to JSON string
      Parameters:
      model - The java object model to convert
      target - Class (or interface) whose annotations to effectively override
      mixinSource - 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 convert
      classz - 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 convert
      classz - 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