I have seen this question and understand the answer, but can not use it in my scenario.
My scenario: I retrieve data via JPA
from a mysql database and want to put this data into a JSONObject
like this
{
"A":["1","2","3"],
"B":["1","2","3","4"],
"C":["1","2"]
}
The problem is I do not know how many arrays I will retrieve. It could be 1 or it could be 200, depending on the data in the database.
If I append
the data into a JSONObject
like this:
import org.apache.tapestry5.json.JSONObject
// ...
JSONObject data = new JSONObject();
for (Value val : values) data.append(val.getName(), val.getValue());
I'll get
{"val_name": [[["1"],"2"],"3"], ...}
Is there a way to use JSONOBject.append
without creating JSONArrays and put
ing them into the JSONObject
, which will result in a nested JSONObject
?