Package io.grpc.internal
Class JsonUtil
java.lang.Object
io.grpc.internal.JsonUtil
Helper utility to work with JSON values in Java types. Includes the JSON dialect used by
Protocol Buffers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckObjectList
(List<?> rawList) Casts a list of unchecked JSON values to a list of checked objects in Java type.checkStringList
(List<?> rawList) Casts a list of unchecked JSON values to a list of String.static Boolean
getBoolean
(Map<String, ?> obj, String key) Gets a boolean from an object for the given key.static List
<?> Gets a list from an object for the given key.getListOfObjects
(Map<String, ?> obj, String key) Gets a list from an object for the given key, and verifies all entries are objects.getListOfStrings
(Map<String, ?> obj, String key) Gets a list from an object for the given key, and verifies all entries are strings.static Double
getNumberAsDouble
(Map<String, ?> obj, String key) Gets a number from an object for the given key.static Float
getNumberAsFloat
(Map<String, ?> obj, String key) Gets a number from an object for the given key.static Integer
getNumberAsInteger
(Map<String, ?> obj, String key) Gets a number from an object for the given key, casted to an integer.static Long
getNumberAsLong
(Map<String, ?> obj, String key) Gets a number from an object for the given key, casted to an long.Gets an object from an object for the given key.static String
Gets a string from an object for the given key.static Long
getStringAsDuration
(Map<String, ?> obj, String key) Gets a string from an object for the given key, parsed as a duration (defined by protobuf).
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
getList
Gets a list from an object for the given key. If the key is not present, this returns null. If the value is not a List, throws an exception. -
getListOfObjects
Gets a list from an object for the given key, and verifies all entries are objects. If the key is not present, this returns null. If the value is not a List or an entry is not an object, throws an exception. -
getListOfStrings
Gets a list from an object for the given key, and verifies all entries are strings. If the key is not present, this returns null. If the value is not a List or an entry is not a string, throws an exception. -
getObject
Gets an object from an object for the given key. If the key is not present, this returns null. If the value is not a Map, throws an exception. -
getNumberAsDouble
Gets a number from an object for the given key. If the key is not present, this returns null. If the value does not represent a double, throws an exception. -
getNumberAsFloat
Gets a number from an object for the given key. If the key is not present, this returns null. If the value does not represent a float, throws an exception. -
getNumberAsInteger
Gets a number from an object for the given key, casted to an integer. If the key is not present, this returns null. If the value does not represent an integer, throws an exception. -
getNumberAsLong
Gets a number from an object for the given key, casted to an long. If the key is not present, this returns null. If the value does not represent a long integer, throws an exception. -
getString
Gets a string from an object for the given key. If the key is not present, this returns null. If the value is not a String, throws an exception. -
getStringAsDuration
Gets a string from an object for the given key, parsed as a duration (defined by protobuf). If the key is not present, this returns null. If the value is not a String or not properly formatted, throws an exception. -
getBoolean
Gets a boolean from an object for the given key. If the key is not present, this returns null. If the value is not a Boolean, throws an exception. -
checkObjectList
Casts a list of unchecked JSON values to a list of checked objects in Java type. If the given list contains a value that is not a Map, throws an exception. -
checkStringList
Casts a list of unchecked JSON values to a list of String. If the given list contains a value that is not a String, throws an exception.
-