i have String from php, let say
stringName={instruction:["1","2","3"]}
and i want to turn tat string into an array
i have try this
stringName= stringName={instruction:["1","2","3"]}
JSONArray menuitemArray = null;
String[] result= null;
try
{
jObject = new JSONObject(stringName);
menuitemArray = jObject.getJSONArray("instruction");
for (int i=0; i<menuitemArray.length(); i++)
{
result[i] = menuitemArray.getJSONArray(i).toString();
}
}
catch (JSONException e1)
{
e1.printStackTrace();
}
but it give me error 🙁
anyone know the right way?
menuitemArray is an array so use
getString(index)method to read an element,And you can’t use
resultarray because it is not initialized. UseList<String>instead of array.