private void saveJson()
{
string[] species = { "Capra hircus", "Panthera pardus", "Equus zebra" };
string[] names = { "Goat", "Leopard", "Zebra" };
// Array
JSONArray values;
values = new JSONArray();
for (int i = 0; i < species.Length; i++) {
JSONObject animal = new JSONObject();
animal.setInt("id", i);
animal.setString("species", species[i]);
animal.setString("name", names[i]);
values.setJSONObject(i, animal);
}
saveJSONArray(values, dataPath + "jsonArray.json");
// Object
JSONObject json = new JSONObject();
json.setInt("id", 0);
json.setString("species", "Panthera leo");
json.setString("name", "Lion");
saveJSONObject(json, dataPath + "jsonObj.json");
}