import org.json.JSONObject; 



 public class Json { 

       

public static void main(String[] args){ 

String jstr = "{\"item\":\"1\",\"name\":\"2\"}";//在java中需要转义符\ 

try { 

JSONObject a = new JSONObject(jstr); 

Iterator it = a.keys(); 

while (it.hasNext()) { 

String key = it.next().toString();//get key 

System.out.println(key); 

String value = a.getString(key);//get value 

System.out.println(value); 

} 

  

} catch (ParseException e) { 

// TODO Auto-generated catch block 

e.printStackTrace(); 

}  

} 

 }