I am having a problem with adding elements to JSON array iteratively using JADE Multi agent platform.
For example, the original JSON array was {["a","b","c]}.
I want my result to be {["a","b","c","1","2"]}.
The JSOn Array element adding should be placed inside a cyclic behaviour.
I got something like this.
i=1
JSONArray array = new JSONArray();
JSONObject jsonObj = new JSONObject();
jsonObj.put("char",array);
addBehaviour(new TickerBehaviour(this,3000) {
array.add( i);
i++;
}
But the result was:
{["a","b","c","1"]}
{["a","b","c","2"]}
If I understand correctly, you need to overwrite the previous object value with the updated one
array.add(i++);
jsonObj.put("char",array);