-
public class AFHelperWraps the given object if necessary. wrap is only available on API19+, so we've copied the implementation. Deviates from the original implementation in that italways returns NULL instead of
{@code null}in case of a failure, andreturns the toString of any object that is of a custom (non-primitive ornon-collection/map) type.If the object is null returns NULL. If the object is a JSONArray or JSONObject, no wrapping is necessary. If the object is NULL, nowrapping is necessary. If the object is an array or Collection, returns an equivalent JSONArray. If the object is a Map, returns an equivalent JSONObject. Ifthe object is a primitive wrapper type or String, returns the object. Otherwise returnsthe result of toString. If wrapping fails, returns JSONObject.NULL.
-
-
Method Summary
Modifier and Type Method Description static JSONObjecttoJsonObject(Map<String, out Object> map)Return a copy of the contents of the given map as a JSONObject. static JSONObjectgetJsonObjectFromString(@Nullable() String json)static Map<String, Object>toMap(@NonNull() JSONObject jsonobj)static List<Object>toList(JSONArray array)-
-
Method Detail
-
toJsonObject
static JSONObject toJsonObject(Map<String, out Object> map)
Return a copy of the contents of the given map as a JSONObject. Instead of failing on
{@code null}values like the JSONObject map constructor, it cleans them up andcorrectly converts them to NULL.
-
getJsonObjectFromString
@Nullable() static JSONObject getJsonObjectFromString(@Nullable() String json)
-
-
-
-