首页 > Web开发 > 详细

JSON JSONObject.fromObject JSONArray.fromObject

时间:2015-09-19 13:36:00      阅读:210      评论:0      收藏:0      [点我收藏+]
	public static void test1(){
		Person person = new Person(); 
		person.setName("zs");
		person.setAge(20);
		JSONObject json = JSONObject.fromObject(person);
		String str = json.toString();
		System.out.println(str);
	
	}
	
	public static void test2(){
		Person person1 = new Person(); 
		person1.setName("zs");
		person1.setAge(20);
		Person person2 = new Person(); 
		person2.setName("ls");
		person2.setAge(24);
		List<Person>  lp = new ArrayList<Person>();
		lp.add(person1);
		lp.add(person2);
		JSONArray json = JSONArray.fromObject(lp);
		String str=json.toString();
		System.out.println(str);
	}

  

JSON JSONObject.fromObject JSONArray.fromObject

原文:http://www.cnblogs.com/hzzhero/p/4821286.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!