java.lang.Object
org.shredzone.acme4j.toolbox.JSONBuilder
Builder for JSON structures.
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionarray
(String key, Collection<?> values) Puts an array.Creates an object for the given key.Puts a property.Puts aDuration
to the JSON.Puts anInstant
to the JSON.Puts binary data to the JSON.Puts aKey
into the claim.toJSON()
Returns aJSON
representation of the current state.toMap()
Returns aMap
representation of the current state.toString()
Returns a JSON string representation of the current state.
-
Constructor Details
-
JSONBuilder
public JSONBuilder()
-
-
Method Details
-
put
Puts a property. If a property with the key exists, it will be replaced.- Parameters:
key
- Property keyvalue
- Property value- Returns:
this
-
put
Puts anInstant
to the JSON. If a property with the key exists, it will be replaced.- Parameters:
key
- Property keyvalue
- PropertyInstant
value- Returns:
this
-
put
Puts aDuration
to the JSON. If a property with the key exists, it will be replaced.- Parameters:
key
- Property keyvalue
- PropertyDuration
value- Returns:
this
- Since:
- 2.3
-
putBase64
Puts binary data to the JSON. The data is base64 url encoded.- Parameters:
key
- Property keydata
- Property data- Returns:
this
-
putKey
Puts aKey
into the claim. The key is serializied as JWK.- Parameters:
key
- Property keypublickey
-PublicKey
to serialize- Returns:
this
-
object
Creates an object for the given key.- Parameters:
key
- Key of the object- Returns:
- Newly created
JSONBuilder
for the object.
-
array
Puts an array.- Parameters:
key
- Property keyvalues
- Collection of property values- Returns:
this
-
toMap
Returns aMap
representation of the current state.- Returns:
Map
of the current state
-
toJSON
Returns aJSON
representation of the current state.- Returns:
JSON
of the current state
-
toString
Returns a JSON string representation of the current state.
-