Java Utililty Methods Json

List of utility methods to do Json

Description

The list of methods to do Json are organized into topic(s).

Method

DoubletoDouble(Object input)
to Double
return ((JsonNumber) input).doubleValue();
JsonArraytoJsonArrayString(Iterator items)
to Json Array String
JsonArrayBuilder builder = Json.createArrayBuilder();
while (items.hasNext()) {
    builder.add(items.next());
return builder.build();
JsonObjectunion(JsonObject... values)
Merges (unions) a list of Json objects into one object.
JsonObjectBuilder builder = Json.createObjectBuilder();
for (JsonObject v : values) {
    for (Map.Entry<String, JsonValue> e : v.entrySet()) {
        builder.add(e.getKey(), e.getValue());
return builder.build();
voidwriteMandatoryDateField(JsonGenerator generator, String fieldName, Date value)
write Mandatory Date Field
String formattedValue = formatDate(value);
writeMandatoryStringField(generator, fieldName, formattedValue);
voidwriteReferenceValue(JsonGenerator generator, Integer value)
Write a reference value (integer or null) into a JsonArray.
if (value == null) {
    generator.write(JsonValue.NULL);
} else {
    generator.write(value);