I've been playing around with the org.json library. I was trying to append a List of Enum types to a json object, but the resulting json array is empty. Here is what I mean:
attribEffects is supposed to hold "HEALTH" and "AMMO" respectively.
{"attr": [
{
"amount": [1000],
"mult": [0],
"attribId": [0],
"time": [-1],
"attribDesc": [null],
"attribName": ["Health Buff (1000)(Debug)"],
"attribEffects": [{}]
},
{
"amount": [5],
"mult": [0],
"attribId": [1],
"time": [5],
"attribDesc": [null],
"attribName": ["devgun_ammo"],
"attribEffects": [{}]
}
]}
Here is where I write to it:
for(Attribute a : (List<Attribute>) l) {
JSONObject j = new JSONObject();
j.append("attribName", a.getAttribName());
j.append("attribId", a.getAttribId());
j.append("attribDesc", a.getAttribDesc());
j.put("attribEffects", a.getEffects());
for(Object o : a.getEffects())
System.out.println(o.toString());
// j.append("attribEffects", a.getAffects()); //TODO: Debug me
j.append("amount", a.getAmount());
j.append("mult", a.getMult());
j.append("time", a.getTime());
root.append("attr", j);
}
The output of the System.out.println for verification:
HEALTH
AMMO
Any ideas?
Edit: I realize having an array for a single value is kind of pointless, but I want this to be expandable in case of having a single thing with multiple effects