这样的事情应该做到:
JSonObject json;Object intervention;JSonArray interventionJsonArray;JSonObject interventionObject;json = RestManager.getJSonfromURL(myuri); // retrieve the entire json stream Object intervention = json.get("intervention");if (intervention instanceof JSONArray) { // It's an array interventionJsonArray = (JSONArray)intervention;}else if (intervention instanceof JSONObject) { // It's an object interventionObject = (JSONObject)intervention;}else { // It's something else, like a string or number}这样做的好处是,
JSONObject只需从一次获取属性值。由于获取属性值涉及遍历哈希树或类似的树,因此对于性能(价值而言)很有用。



