i'm having a problem with saving my results to file. I have 2 Arraylists
ArrayList<List<Integer>>positions
ArrayList<List<Integer>>positions2
with data format like this:
[[0,32],[39,19],[60,15],...]
I want to save this data to JSON file format like this:
"collocation": {
"first": [[0,32],[39,19],[60,15],...],
"second": [[0,32],[39,19],[60,15],...]}
I tried following code to create first object
JSONArray JsonArray = new JSONArray(positions);
JSONObject Jsonobject = new JSONObject();
Jsonobject.put("first",JsonArray);
String jsooo = new Gson().toJson(Jsonobject);
And i end up with results:
{"map":{"first":{"myArrayList":[{"myArrayList":[0,32]},{"myArrayList":[39,19]},{"myArrayList":[60,15]}}
Why i'm getting "map" and "myArrayList" and how i can avoid/remove it to get what i want?
So, what i need to do to get format i need? This occurs only then i execute put(), but i dont know other ways to create structure like i need.