当前位置 : 主页 > 编程语言 > java >

通过fastJSON封装JSON

来源:互联网 收集:自由互联 发布时间:2021-06-28
通过fastJSON封装JSON package com.itmayiedu.dao;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;public class Json {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stu
通过fastJSON封装JSON
package com.itmayiedu.dao;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class Json {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		setFastJSON();
	}
	/**
	 * 通过fastJSON封装JSON
	 */

	public static void setFastJSON() {
		JSONObject root = new JSONObject();
		root.put("error", "0");
		root.put("success", "1");
		JSONArray dataArr=new JSONArray();
		JSONObject userWJQ=new JSONObject();
		userWJQ.put("username", "wjq");
		userWJQ.put("position", "学生");
		dataArr.add(userWJQ);
		root.put("data", dataArr);
		System.out.println(root.toString());
	}

}
上一篇:ASCII string 互转
下一篇:list对象排序
网友评论