好的,似乎没有互操作性,所以我自己动手了。忙于避开类型系统:
public class Util { public static DBObject enpre(JSonArray a) { BasicDBList result = new BasicDBList(); try { for (int i = 0; i < a.length(); ++i) { Object o = a.get(i); if (o instanceof JSONObject) { result.add(enpre((JSONObject)o)); } else if (o instanceof JSONArray) { result.add(enpre((JSONArray)o)); } else { result.add(o); } } return result; } catch (JSonException je) { return null; } } public static DBObject enpre(JSonObject o) { BasicDBObject result = new BasicDBObject(); try { Iterator i = o.keys(); while (i.hasNext()) { String k = (String)i.next(); Object v = o.get(k); if (v instanceof JSONArray) { result.put(k, enpre((JSONArray)v)); } else if (v instanceof JSONObject) { result.put(k, enpre((JSONObject)v)); } else { result.put(k, v); } } return result; } catch (JSonException je) { return null; } }}


