How do I clone an org.json.JSONObject in Java?

Is there a way to clone an instance of org.json.JSONObject without stringifying it and reparsing the result?

A shallow copy would be acceptable.


Easiest (and incredibly slow and inefficient) way to do it

JSONObject clone = new JSONObject(original.toString());

Use the public JSONObject(JSONObject jo, java.lang.String[] names) constructor and the public static java.lang.String[] getNames(JSONObject jo) method.

JSONObject copy = new JSONObject(original, JSONObject.getNames(original));