java操作json全jar包
使用JSONObject, JSONArray的全套完整jar包,绝对好用。另外附上例子一枚 package com.jjzy.test; import java.util.Iterator; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class TestJson { public static void main(String[] args) { String gg = "{\"name\":[\"啦啦\",\"哈哈\"]}"; JSONObject jsonObject = JSONObject.fromObject(gg); JSONArray jsonArr = jsonObject.getJSONArray("name"); @SuppressWarnings("unchecked") Iterator it = jsonArr.iterator(); whi le(it.hasNext()){ String ff = (String)it.next(); System.out.println("获取的是:"+ff); } } } le(it.hasNext()){ String ff = (String)it.next(); System.out.println("获取的是:"+ff); } } }
用户评论