I can't get the array length of the JSON array. when I using length(); method it is not working, it show as red underline in Netbeans
this is the source code
try { JSONObject myjson = JSONObject.fromObject(practiceInfoByUsername); //JSONArray nameArray = myjson.names(); final JSONArray jar = myjson.getJSONArray("_types"); for(int i=0; i<jar.length(); i++) { String p = jar.getString(i); Log.i("p",p); } } catch (JSONException e) { e.printStackTrace(); }
To obtain the size of a JSON-encoded array or object, use the json_size function, and specify the column containing the JSON string and the JSONPath expression to the array or object. To use the Amazon Web Services Documentation, Javascript must be enabled.
The maximum length of a JSON type using a binary storage format is 16776192 bytes.
Note: if you're using(importing) org.json.simple.JSONArray
, you have to use JSONArray.size()
to get the data you want. But use JSONArray.length()
if you're using org.json.JSONArray
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With