Package org.bstats.json
Class JsonObjectBuilder
- java.lang.Object
-
- org.bstats.json.JsonObjectBuilder
-
public class JsonObjectBuilder extends java.lang.ObjectAn extremely simple JSON builder.While this class is neither feature-rich nor the most performant one, it's sufficient enough for its use-case.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonObjectBuilder.JsonObjectA super simple representation of a JSON object.
-
Constructor Summary
Constructors Constructor Description JsonObjectBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonObjectBuilderappendField(java.lang.String key, int value)Appends an integer field to the JSON.JsonObjectBuilderappendField(java.lang.String key, int[] values)Appends an integer array to the JSON.JsonObjectBuilderappendField(java.lang.String key, java.lang.String value)Appends a string field to the JSON.JsonObjectBuilderappendField(java.lang.String key, java.lang.String[] values)Appends a string array to the JSON.JsonObjectBuilderappendField(java.lang.String key, JsonObjectBuilder.JsonObject object)Appends an object to the JSON.JsonObjectBuilderappendField(java.lang.String key, JsonObjectBuilder.JsonObject[] values)Appends an object array to the JSON.JsonObjectBuilderappendNull(java.lang.String key)Appends a null field to the JSON.JsonObjectBuilder.JsonObjectbuild()Builds the JSON string and invalidates this builder.
-
-
-
Method Detail
-
appendNull
public JsonObjectBuilder appendNull(java.lang.String key)
Appends a null field to the JSON.- Parameters:
key- The key of the field.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, java.lang.String value)
Appends a string field to the JSON.- Parameters:
key- The key of the field.value- The value of the field.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, int value)
Appends an integer field to the JSON.- Parameters:
key- The key of the field.value- The value of the field.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, JsonObjectBuilder.JsonObject object)
Appends an object to the JSON.- Parameters:
key- The key of the field.object- The object.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, java.lang.String[] values)
Appends a string array to the JSON.- Parameters:
key- The key of the field.values- The string array.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, int[] values)
Appends an integer array to the JSON.- Parameters:
key- The key of the field.values- The integer array.- Returns:
- A reference to this object.
-
appendField
public JsonObjectBuilder appendField(java.lang.String key, JsonObjectBuilder.JsonObject[] values)
Appends an object array to the JSON.- Parameters:
key- The key of the field.values- The integer array.- Returns:
- A reference to this object.
-
build
public JsonObjectBuilder.JsonObject build()
Builds the JSON string and invalidates this builder.- Returns:
- The built JSON string.
-
-