我有以下 json 格式的字符串:
String s = "{ \"_id\" : \"foo.com\", \"categories\" : [], \"ho\" : { \"bnMzMC5==\" : { \"first\" : 1281916800, \"last\" : 1316995200 }, \"bnMyOS5kb21==\" : { \"first\" : 1281916800, \"last\" : 1316995200 } }, \"name\" : [ \"ns.foo.com\", \"ns.bar.com\" ], \"reputation\" : null }";
JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(s);
String output = "";
for (Object rkey : json.keySet()) {
Object val = json.get(rkey);
output += rkey.toString() + "\t" + val.toString() +"\t";
System.out.println(rkey + " "+ val.toString());
}
但我得到了这个例外:
Exception in thread "main" java.lang.NullPointerException
at org.random_scripts.JsonRead.main(JsonRead.java:25)
我错过了什么