Java – Converts a HashMap’s ArrayList to a JSON String

Converts a HashMap’s ArrayList to a JSON String… here is a solution to the problem.

Converts a HashMap’s ArrayList to a JSON String

I’m going to convert ArrayList<Hashmap<String, String>> to JSONArray

JSONArray array = new JSONArray(array_list);

But it doesn’t work properly it returns

["{image=2130837526, category=Chairs, Quantity=1, price=400, name=chair, prodId=34}","{image=2130837566, category=Mirrors, Quantity=1, price=3000, name=La Fonda, prodId=35}"]

It should return

cartitems=[{"name":"Chair","price":"1001","prodId":"2","category":"Chairs","image":"2130837519","Quantity":"1"},{"name":"Baxton Studio Club Chair","price":" 4545","prodId":"5","category":"Chairs","image":"2130837521","Quantity":"1"}]

Related Problems and Solutions