Convert normal Java Array or ArrayList to Json Array in android

If you want or need to work with a Java array then you can always use the java.util.Arrays utility classes’ static asList() method to convert your array to a List.

Something along those lines should work.

String mStringArray[] = { "String1", "String2" };

JSONArray mJSONArray = new JSONArray(Arrays.asList(mStringArray));

Beware that code is written offhand so consider it pseudo-code.

Leave a Comment