Class JSONArrayUtils

java.lang.Object
com.nimbusds.oauth2.sdk.util.JSONArrayUtils

public final class JSONArrayUtils extends Object
JSON array helper methods for parsing and typed retrieval of values.
  • Method Details

    • parse

      public static net.minidev.json.JSONArray parse(String s) throws ParseException
      Parses a JSON array.

      Specific JSON to Java entity mapping (as per JSON Simple):

      • JSON numbers mapped to java.lang.Number.
      • JSON integer numbers mapped to long.
      • JSON fraction numbers mapped to double.
      Parameters:
      s - The JSON array string to parse. Must not be null.
      Returns:
      The JSON array.
      Throws:
      ParseException - If the string cannot be parsed to a JSON array.
    • toStringList

      public static List<String> toStringList(net.minidev.json.JSONArray jsonArray)
      Converts the specified JSON array to a string list.
      Parameters:
      jsonArray - The JSON array. May be null.
      Returns:
      The corresponding string list, empty list if the JSON array is null or empty.
    • toURIList

      public static List<URI> toURIList(net.minidev.json.JSONArray jsonArray) throws ParseException
      Converts the specified JSON array to a URI list.
      Parameters:
      jsonArray - The JSON array. May be null.
      Returns:
      The corresponding URI list, empty list if the JSON array is null or empty.
      Throws:
      ParseException - If a JSON array item couldn't be parsed to a URI.
    • toJSONObjectList

      public static List<net.minidev.json.JSONObject> toJSONObjectList(net.minidev.json.JSONArray jsonArray) throws ParseException
      Converts the specified JSON array to a JSON object list.
      Parameters:
      jsonArray - The JSON array. May be null.
      Returns:
      The corresponding JSON object list, empty list if the JSON array is null or empty.
      Throws:
      ParseException - If a JSON array item couldn't be parsed to a JSON object.