首页 > 技术文章 > json使用

huhuuu 2015-03-10 16:24 原文

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);

    }

}

 

推荐阅读