json - Converting List<object> to JSONArray using java -
im using java play2 framework 2.3.x , ebean orm when try convert beanlist jsonarray/jsonnode takes more time using arraylist created looping on beanlist , added arraylist, lets when time taken convert arraylist x, beanlist takes 3x.
public class mybean extends model { private string name; public string getname() { return this.name; } public void setname(string name) { this.name = name; } }
when
list<mybean> mybean = mybean.find.all();//will return beanlist<device> jsonarray mybeanjsonlist = new jsonarray(mybean);
or
jsonnode mybeanlist = json.tojson(mybean);
takes more time looping on beanlist , add object in arraylist
list<mybean> mybean = mybean.find.all();//will return beanlist<device> list<mybean> mybeanlist = new arraylist<device>(); for(mybean d : mybean) { mybean mybeantemp = new mybean(); mybeantemp.setname(d.getname()); mybeanlist.add(mybeantemp); } jsonarray mybeanjsonlist = new jsonarray(mybeanlist);
or
jsonnode mybeanjsonlist = json.tojson(mybeanlist);
is normal behavior?
Comments
Post a Comment