List of utility methods to do Json
JsonObjectBuilder | addAll(JsonObjectBuilder a, JsonObjectBuilder b) add All Objects.requireNonNull(a);
Objects.requireNonNull(b);
return addAll(a, b.build());
|
JsonObject | asJsonObject(JsonValue value) as Json Object return JsonObject.class.cast(value); |
String | asString(JsonValue value) as String if (JsonValue.ValueType.STRING.equals(value.getValueType())) { return ((JsonString) value).getString(); return value.toString(); |
boolean | compare(JsonValue expected, JsonValue actual, boolean strict) compare switch (expected.getValueType()) { case OBJECT: if (actual.getValueType() == ValueType.OBJECT) { return jsonEquals((JsonObject) expected, (JsonObject) actual, strict); break; case ARRAY: if (actual.getValueType() == ValueType.ARRAY) { ... |
Object | convertJsonValue(Object jsonValue, Class desiredType) convert Json Value if (jsonValue instanceof JsonNumber) { JsonNumber number = (JsonNumber) jsonValue; if (desiredType == null || desiredType == Long.class || desiredType == Long.TYPE) { return number.longValue(); } else if (desiredType == Integer.class || desiredType == Integer.TYPE) { return number.intValue(); } else if (desiredType == Double.class || desiredType == Double.TYPE) { return number.doubleValue(); ... |
String | escape(String text) Escape a string. if (text == null) return null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); switch (ch) { case '"': sb.append("\\\""); ... |
void | fill_dictionary(Map fildictionary if (dictionary == null || jsonObject == null) { return; for (String key : jsonObject.keySet()) { JsonValue valueObj = (JsonValue) jsonObject.get(key); JsonValue.ValueType type = valueObj.getValueType(); if (type == JsonValue.ValueType.ARRAY) { JsonArray arrayObj = jsonObject.getJsonArray(key); ... |
void | fill_key_value(JsonObjectBuilder jsonObject, String key, Object value) filkevalue if (jsonObject == null || key == null) { return; if (value == null) { jsonObject.addNull(key); } else if (value instanceof String) { jsonObject.add(key, (String) value); } else if (value instanceof Integer) { ... |
void | fill_list(JsonObjectBuilder jsonObject, String key, List fillist if (jsonObject == null || key == null) { return; JsonArrayBuilder arrayBuilder = jsonFactory.createArrayBuilder(); for (Object entry : list) { if (entry instanceof Map) { JsonObjectBuilder entryObj = jsonFactory.createObjectBuilder(); fill_map(entryObj, (Map<String, Object>) entry); ... |
String | fromDictionary(Map from Dictionary if (dictionary == null) { return null; JsonObjectBuilder root = jsonFactory.createObjectBuilder(); fill_map(root, dictionary); return root.build().toString(); |