public class DefaultJsonObject extends Object implements JsonObject
OAuth2ServiceConfiguration does not
provide all required properties.| Constructor and Description |
|---|
DefaultJsonObject(String jsonString)
Create an instance
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(String key) |
java.time.Instant |
getAsInstant(String name)
Returns an
Instant identified by the given property name. |
<T> List<T> |
getAsList(String name,
Class<T> type)
Parses the json object for the given property
name and returns a list
of type T. |
String |
getAsString(String name)
Returns the string identified by the given property
name. |
JsonObject |
getJsonObject(String name)
Returns a nested JSON object as @{link JsonObject} instance.
|
List<JsonObject> |
getJsonObjects(String name)
Returns a nested array of JSON objects as list of
JsonObject
instances. |
Map<String,String> |
getKeyValueMap()
Returns a key-value map of the JSON properties.
|
boolean |
isEmpty()
Method to check if the underlying json object is empty.
|
public DefaultJsonObject(String jsonString)
jsonString - the content in json format that should be parsed.public boolean contains(String key)
contains in interface JsonObjectkey - the name of the property.public boolean isEmpty()
JsonObjectisEmpty in interface JsonObjectpublic <T> List<T> getAsList(String name, Class<T> type)
JsonObjectname and returns a list
of type T. If the property with the given name is not found, an empty
list is returned.getAsList in interface JsonObjectT - the type of the list elements.name - the property inside this json object which contains a list as
values of type T.type - type parameter for generic type T.T.@Nullable public String getAsString(String name)
JsonObjectname. If the
property with the given name is not found, null is returned.getAsString in interface JsonObjectname - the name of the property.@Nullable public java.time.Instant getAsInstant(String name)
JsonObjectInstant identified by the given property name. If
the property with the given name is not found, null is returned.getAsInstant in interface JsonObjectname - the name of the property.Instant object.@Nullable public JsonObject getJsonObject(String name)
JsonObjectgetJsonObject in interface JsonObjectname - the name of property.JsonObject.public List<JsonObject> getJsonObjects(String name)
JsonObjectJsonObject
instances. If the property with the given name is not found, an empty list is
returned.getJsonObjects in interface JsonObjectname - the name of property.JsonObject instances.public Map<String,String> getKeyValueMap()
JsonObject
String vcapServices = System.getenv(CFConstants.VCAP_SERVICES);
JsonObject serviceJsonObject = new DefaultJsonObject(vcapServices).getJsonObjects(Service.XSUAA.getCFName())
.get(0);
Map<String, String> xsuaaConfigMap = serviceJsonObject.getKeyValueMap();
Map<String, String> credentialsMap = serviceJsonObject.getJsonObject(CFConstants.CREDENTIALS)
.getKeyValueMap();
getKeyValueMap in interface JsonObjectCopyright © 2020. All rights reserved.