Improved JSONObject conversion