Take for example the class JSONObject.
And say I have the following method.
public JSONObject getObjectOrThrow(String name) {
JSONObject jsonObject = null;
try {
jsonObject = JSON.getJSONObject(name);
} catch (Exception e) {
System.out.println("JSON_ERROR : " + name);
e.printStackTrace();
}
return jsonObject;
}
How do I extend the JSONObject so that I'll end up with a method like.
JSONObject man = new JSONObject("name");
man.getObjectOrThrow("name");
Where "name" is the key to the child node of "man".
Also for reference, what is this called?