java - JSONArray object have getString(""); not found -
imported header files are:
import org.json.simple.jsonarray; import org.json.simple.parser.parseexception; import org.json.simple.parser.jsonparser; the line string name= jsonarray.getstring("name");
causes error: getstring("") not found
that's because jsonarray doesn't have getstring() method. matter, jsonobject doesn't have getstring() method.
we can guess without knowing jsonarray contains, guess need,
string name= (string) ((jsonobject) jsonarray.get(0)).get("name"); edit: based on comment, think jsonarray of type jsonobject (not sure though), in case use,
string name = (string) jsonarray.get("name");
Comments
Post a Comment