public class JSONBuilder extends Object
Example:
JSONBuilder cb = new JSONBuilder();
cb.put("foo", 123).put("bar", "hello world");
cb.object("sub").put("data", "subdata");
cb.array("array", 123, 456, 789);
| Constructor and Description |
|---|
JSONBuilder() |
| Modifier and Type | Method and Description |
|---|---|
JSONBuilder |
array(String key,
Object... values)
Puts an array.
|
JSONBuilder |
object(String key)
Creates an object for the given key.
|
JSONBuilder |
put(String key,
Instant value)
Puts an
Instant to the JSON. |
JSONBuilder |
put(String key,
Object value)
Puts a property.
|
JSONBuilder |
putBase64(String key,
byte[] data)
Puts binary data to the JSON.
|
JSONBuilder |
putKey(String key,
PublicKey publickey)
Puts a
Key into the claim. |
JSONBuilder |
putResource(Resource resource)
Puts a resource.
|
JSONBuilder |
putResource(String resource)
Puts a resource.
|
JSON |
toJSON()
Returns a
JSON representation of the current state. |
Map<String,Object> |
toMap()
Returns a
Map representation of the current state. |
String |
toString()
Returns a JSON string representation of the current state.
|
public JSONBuilder()
public JSONBuilder put(String key, Object value)
key - Property keyvalue - Property valuethispublic JSONBuilder put(String key, Instant value)
Instant to the JSON. If a property with the key exists, it will be
replaced.key - Property keyvalue - Property Instant valuethispublic JSONBuilder putResource(String resource)
resource - Resource namethispublic JSONBuilder putResource(Resource resource)
resource - Resourcethispublic JSONBuilder putBase64(String key, byte[] data)
key - Property keydata - Property datathispublic JSONBuilder putKey(String key, PublicKey publickey)
Key into the claim. The key is serializied as JWK.key - Property keypublickey - PublicKey to serializethispublic JSONBuilder object(String key)
key - Key of the objectJSONBuilder for the object.public JSONBuilder array(String key, Object... values)
key - Property keyvalues - Array of property valuesthispublic Map<String,Object> toMap()
Map representation of the current state.Map of the current statepublic JSON toJSON()
JSON representation of the current state.JSON of the current stateCopyright © 2015–2019. All rights reserved.