第一种用Android自带的 org.Json包
package Test.action;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
//用之前先把org.json包里面的类 全部放到项目里
public class TestJson {
public static void main(String[] args) throws JSONException {
String str1 = "{name:'wangyafei',age:'20',sex:'man',fav:{1:'money',2:'money too'}}";
JSONObject jsonObject = new JSONObject(str1);
System.out.println(jsonObject.get("name"));
System.out.println(jsonObject.get("age"));
JSONObject fav = jsonObject.getJSONObject("fav");
System.out.println(fav.get("1"));
System.out.println(fav.get("2"));
jsonObject.put("add", "mafang");
System.out.println(jsonObject.toString());
// -----------------------------