I am using Processing 3.5.3 and using the IDE on a Mac. I am using Java mode.
The code I have in the sketch is:
JSONArray values;
void setup() {
values = loadJSONArray("data.json");
for (int i = 0; i < values.size(); i++) {
JSONObject animal = values.getJSONObject(i);
int id = animal.getInt("id");
String species = animal.getString("species");
String name = animal.getString("name");
println(id + ", " + species + ", " + name);
}
}
In the data folder I have a file “data.json” that contains:
[
{
"id": 0,
"species": "Capra hircus",
"name": "Goat"
},
{
"id": 1,
"species": "Panthera pardus",
"name": "Leopard"
},
{
"id": 2,
"species": "Equus zebra",
"name": "Zebra"
}
]
On the Mac, the produces the error cited in my original post:
“cannot convert from processing.data.JSONArray to JSONArray”
However, I tried this on a Windows machine and it ran fine.