Here you can find the source of getStringArray(JSONArray jsonArray)
Parameter | Description |
---|---|
jsonArray | the JSONArray to convert |
Parameter | Description |
---|---|
JSONException | exception during JSON parsing |
public static String[] getStringArray(JSONArray jsonArray) throws JSONException
//package com.java2s; import org.json.JSONArray; import org.json.JSONException; public class Main { /**/*from w w w . j av a 2s .c o m*/ * A helper method to convert one dimensional JSONArrays to StringArrays. * @param jsonArray the JSONArray to convert * @return stringArray the converted StringArray * @throws JSONException exception during JSON parsing */ public static String[] getStringArray(JSONArray jsonArray) throws JSONException { String[] stringArray = new String[jsonArray.length()]; for (int i = 0; i < jsonArray.length(); i++) { stringArray[i] = jsonArray.getString(i); } return stringArray; } }