JAVA中如何将一个json形式的字符串转为json对象

import java.io.*;  
import org.json.*;  
  
public class Demo {  
    public static void main(String[] args) throws Exception {  
        String str = "{\"a\":\"b\", \"c\":\"d\"}";  
        JSONObject a = new JSONObject(str);  
        System.out.println(a); // {"c":"d","a":"b"}  
        System.out.println(a.get("c")); // d  
    }  
}  

 

posted @ 2015-09-23 20:32  netcorner  阅读(19826)  评论(0编辑  收藏  举报