I try to go in JSONObject
but I don’t find a solution to go inside, except if I use knew key
. But my purpose is going to the object to grad all informations from it, I don’t know the information in advance.
I see the JSONObject
is an HashMap
, but when I try to apply the function from HashMap
like values()
this function is not recognize, but size()
yes.
JSONObject list = item.getJSONObject("density");
println("list",list);
println("list size",list.size());
console log
list {
"gaz": 1.429,
"liquid": 1.141
}
list.size() 2
but when I try
for(Float f : list.values()) {
println("float", f);
}
the console return
R_Atom.pde:53:0:53:0: The function values() does not exist.
I try the classic way too with
for(int i = 0 ; i < list.size() ; i++) {
println(list.get(i));
}
R_Atom.pde:65:0:65:0: The method get(String) in the type JSONObject is not applicable for the arguments (int)
So my question is how loop in JSON Object to grab the object ?