Package com.nimbusds.oauth2.sdk.util
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static net.minidev.json.JSONArray
parse(String s)
Parses a JSON array.static List<net.minidev.json.JSONObject>
toJSONObjectList(net.minidev.json.JSONArray jsonArray)
Converts the specified JSON array to a JSON object list.static List<String>
toStringList(net.minidev.json.JSONArray jsonArray)
Converts the specified JSON array to a string list.static List<URI>
toURIList(net.minidev.json.JSONArray jsonArray)
Converts the specified JSON array to a URI list.
-
-
-
Method Detail
-
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 benull
.- Returns:
- The JSON array.
- Throws:
ParseException
- If the string cannot be parsed to a JSON array.
- JSON numbers mapped to
-
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 benull
.- 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 benull
.- 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 benull
.- 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.
-
-