JsonValue implements Parcelable, JsonSerializable { @NonNull @Override public String toString() { if (isNull()) { return "null"; } try { if (value instanceof String) { return JSONObject.quote((String) value); } if (value instanceof Number) { return JSONObject.numberToString((Number) value); } if (value instanceof JsonMap || value instanceof JsonList) { return value.toString(); } return String.valueOf(value); } catch (JSONException e) { Logger.error(e, "JsonValue - Failed to create JSON String."); return ""; } } private  JsonValue(@Nullable Object value); @Nullable Object getValue(); @Nullable String getString(); @NonNull String getString(@NonNull String defaultValue); @NonNull String optString(); int getInt(int defaultValue); float getFloat(float defaultValue); double getDouble(double defaultValue); long getLong(long defaultValue); @Nullable Number getNumber(); boolean getBoolean(boolean defaultValue); @Nullable JsonList getList(); @NonNull JsonList optList(); @Nullable JsonMap getMap(); @NonNull JsonMap optMap(); boolean isNull(); boolean isString(); boolean isInteger(); boolean isDouble(); boolean isFloat(); boolean isLong(); boolean isNumber(); boolean isBoolean(); boolean isJsonMap(); boolean isJsonList(); @NonNull static JsonValue parseString(@Nullable String jsonString); @Override boolean equals(@Nullable Object object); @Override int hashCode(); @NonNull @Override String toString(); @NonNull static JsonValue wrap(@Nullable String value); @NonNull static JsonValue wrap(char value); @NonNull static JsonValue wrap(int value); @NonNull static JsonValue wrap(long value); @NonNull static JsonValue wrap(boolean value); @NonNull static JsonValue wrap(double value); @NonNull static JsonValue wrap(@Nullable JsonSerializable value); @NonNull static JsonValue wrapOpt(@Nullable Object object); @NonNull static JsonValue wrap(@Nullable Object object, @NonNull JsonValue defaultValue); @NonNull static JsonValue wrap(@Nullable Object object); @Override int describeContents(); @Override void writeToParcel(@NonNull Parcel dest, int flags); @NonNull @Override JsonValue toJsonValue(); @NonNull
    final static JsonValue NULL; @NonNull
    static final Parcelable.Creator<JsonValue> CREATOR; }
@Test public void testToString() throws JsonException, JSONException { assertEquals("\"Hello\"", JsonValue.wrap("Hello").toString()); assertEquals("1", JsonValue.wrap(1).toString()); assertEquals(String.valueOf(Long.MAX_VALUE), JsonValue.wrap(Long.MAX_VALUE).toString()); assertEquals("1.2", JsonValue.wrap(1.2).toString()); assertEquals("true", JsonValue.wrap(true).toString()); assertEquals("false", JsonValue.wrap(false).toString()); assertEquals("null", JsonValue.NULL.toString()); Map<String, Object> map = new HashMap<>(primitiveMap); map.put("map", primitiveMap); map.put("collection", primitiveList); JsonValue expected = JsonValue.parseString("{\"short\":3,\"char\":\"c\",\"byte\":2,\"int\":1,\"String\":\"String\"," + "\"map\":{\"short\":3,\"byte\":2,\"char\":\"c\",\"String\":\"String\",\"int\":1," + "\"boolean\":true,\"double\":1.2},\"boolean\":true,\"collection\":[\"String\",1.2," + "false,1,\"c\",2,3],\"double\":1.2}"); assertEquals(expected.getMap(), JsonValue.wrap(map)); List<Object> list = new ArrayList<>(primitiveList); list.add(primitiveList); expected = JsonValue.parseString("[\"String\",1.2,false,1,\"c\",2,3,[\"String\",1.2,false,1,\"c\",2,3]]"); assertEquals(expected.getList(), JsonValue.wrap(list).getList()); }