Class JsonUtils


  • public class JsonUtils
    extends Object
    Utility class for JSON objects
    Author:
    Sebastien Briquet - sebfz1
    • Method Detail

      • toArray

        public static com.github.openjson.JSONArray toArray​(String[] values)
        Converts an array of String to a JSONArray of (quoted) strings
        Parameters:
        values - the array of strings
        Returns:
        a JSONArray
      • toArray

        public static com.github.openjson.JSONArray toArray​(Enum<?>[] values)
        Converts an array of enums to a JSONArray of (quoted) strings
        Parameters:
        values - the array of strings
        Returns:
        a JSONArray
      • toList

        public static List<Object> toList​(com.github.openjson.JSONArray values)
        Converts a JSONArray to a List of Objects
        Parameters:
        values - the JSONArray
        Returns:
        a new List
      • toJSONList

        public static List<com.github.openjson.JSONObject> toJSONList​(com.github.openjson.JSONArray values)
        Converts a JSONArray to a List of JSONObjects
        Parameters:
        values - the JSONArray
        Returns:
        a new List
      • toString

        public static String toString​(List<?> list)
        Converts a List to its JSON string representation
        Parameters:
        list - the List to convert
        Returns:
        a new JSON String
      • toString

        public static String toString​(Object object)
        Converts a Object to its JSON string representation
        Parameters:
        object - the Object to convert
        Returns:
        a new JSON String
      • newJSONObject

        public static com.github.openjson.JSONObject newJSONObject​(String name,
                                                                   Object value)
        Gets a new JSONObject
        Parameters:
        name - the field name
        value - the field value
        Returns:
        a new JSONObject