Package com.nimbusds.oauth2.sdk.util
Class JSONUtils
java.lang.Object
com.nimbusds.oauth2.sdk.util.JSONUtils
JSON helper methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Parses a JSON value.static Object
Parses a JSON value while keeping the order of JSON object members.static <T> T
Casts an object.static boolean
Casts an object to a boolean.static List<?>
Casts an object to a list.static Number
Casts an object to a number.static String
Casts an object to a string.Casts an object to a list then returns a string list copy of it casting each item to a string.
-
Method Details
-
parseJSON
Parses a JSON value.- Parameters:
s
- The JSON string to parse. Must not benull
.- Returns:
- The JSON value.
- Throws:
ParseException
- If the string cannot be parsed to a JSON value.
-
parseJSONKeepingOrder
Parses a JSON value while keeping the order of JSON object members.- Parameters:
s
- The JSON string to parse. Must not benull
.- Returns:
- The JSON value.
- Throws:
ParseException
- If the string cannot be parsed to a JSON value.
-
to
Casts an object.- Parameters:
o
- The object. Must not benull
.clazz
- The expected class of the object. Must not benull
.- Returns:
- The cast object.
- Throws:
ParseException
- If the object is not of the expected type.
-
toBoolean
Casts an object to a boolean.- Parameters:
o
- The object. Must not benull
.- Returns:
- The boolean value.
- Throws:
ParseException
- If the object is not of the expected type.
-
toNumber
Casts an object to a number.- Parameters:
o
- The object. Must not benull
.- Returns:
- The number.
- Throws:
ParseException
- If the object is not of the expected type.
-
toString
Casts an object to a string.- Parameters:
o
- The object. Must not benull
.- Returns:
- The string.
- Throws:
ParseException
- If the object is not of the expected type.
-
toList
Casts an object to a list.- Parameters:
o
- The object. Must not benull
.- Returns:
- The list.
- Throws:
ParseException
- If the object is not of the expected type.
-
toStringList
Casts an object to a list then returns a string list copy of it casting each item to a string.- Parameters:
o
- The object. Must not benull
.- Returns:
- The string list.
- Throws:
ParseException
- If the object is not of the expected type.
-