雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

json使用

Posted on 2015-03-10 16:24  huhuuu  阅读(210)  评论(0编辑  收藏  举报
package helloworld;

import com.XX.fastjson.JSONArray;
import com.XX.fastjson.JSONObject;

public class test {

    public static void main(String[] args) {
        JSONArray array = new JSONArray();
        
        
        int i;
        for(i = 1; i <= 3; i++){
            JSONObject json = new JSONObject();
            json.put("type", "paragraph"+String.valueOf(i));
            array.add(json);
        }
        
        String jsonStr = array.toString();

        System.out.println(jsonStr);

    }

}