Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert ArrayList to JSONArray

This is my ArrayList

ArrayList< HashMap < String,String> > list =  new ArrayList<>();

which holds hashmap.

How to acquire all the hashmaps in Plain JSONArray?

like image 968
Vaibhav Kadam Avatar asked Dec 10 '22 16:12

Vaibhav Kadam


1 Answers

We can do something like this,

ArrayList< HashMap < String,String> > list =  new ArrayList<>();

and then just pass List object to JsonArray like this

JSONArray jsArray = new JSONArray(list);

thankew!

like image 172
Vaibhav Kadam Avatar answered Jan 03 '23 11:01

Vaibhav Kadam