基于jQuery的AJAX和JSON的实例
http://www.cnblogs.com/yangy608/archive/2010/11/22/1884333.html
http://wenku.baidu.com/view/8d2fb34bcf84b9d528ea7a32.html
org.json
http://blog.csdn.net/xiazdong/article/details/7059573
http://blog.csdn.net/xiazdong/article/details/7059573
org.json
package technology;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Json1 {
/**
* @param args
* @throws JSONException
*/
public static void main(String[] args) throws JSONException {
test1();
}
public static void test1() throws JSONException{
//{"point":{"x":10,"y":20,"name":"hello"}}
String string="{\"point\":{\"x\":10,\"y\":20,\"name\":\"hello\"}}";
JSONObject json=new JSONObject(string);
JSONObject point=json.getJSONObject("point");
System.out.println(point.getString("name")+"--"+point.getInt("x")+"--"+point.getInt("y"));
//{"name":["one","two","three"]}
string="{\"name\":[\"one\",\"two\",\"three\"]}";
json=new JSONObject(string);
JSONArray jsonArray=json.getJSONArray("name");
for(int i=0;i<jsonArray.length();i++)
System.out.println("array"+jsonArray.getString(i));
}
}