import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class testMain {
/**
* @param args
*/
public static void main(String[] args) {
MyBean myBean = new MyBean();
myBean.setId(1);
myBean.setName("one");
MyBean myBean2 = new MyBean();
myBean2.setId(2);
myBean2.setName("two");
List
mybeanList.add(myBean);
mybeanList.add(myBean2);
JSONArray jsonArray = JSONArray.fromObject(mybeanList);
System.out.println("mybean list -----"+jsonArray);
Map
map0.put("success", true);
JSONObject mapObject = JSONObject.fromObject(map0);
System.out.println("map0 - "+mapObject);
Map
map.put("data", jsonArray);
JSONObject jsonObject = JSONObject.fromObject(map);
System.out.println("json - "+jsonObject);
}
}
No comments:
Post a Comment