Package com.nimbusds.oauth2.sdk.util
Class JSONArrayUtils
java.lang.Object
com.nimbusds.oauth2.sdk.util.JSONArrayUtils
JSON array helper methods for parsing and typed retrieval of values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minidev.json.JSONArray
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.toStringList
(net.minidev.json.JSONArray jsonArray) Converts the specified JSON array to a string list.toURIList
(net.minidev.json.JSONArray jsonArray) Converts the specified JSON array to a URI list.
-
Method Details
-
parse
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
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
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.
-