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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -