创建JSONObject时java-org.json未报告的异常
发布时间:2020-12-16 19:32:23 所属栏目:百科 来源:网络整理
导读:谁能帮我理解出了什么问题? unreported exception org.json.JSONException; must be caught or declared to be thrown jsonObj = new JSONObject("{"count":3939,"has_more":true,"map_location":{"lat":0.60996950000000183,"lon":-27.568517000
谁能帮我理解出了什么问题?
unreported exception org.json.JSONException; must be caught or declared to be thrown jsonObj = new JSONObject("{"count":3939,"has_more":true,"map_location":{"lat":0.60996950000000183,"lon":-27.568517000000003,"panoramio_zoom":16},"photos":[{"height":375,}]}"); //creates the JSON object from the jsonString,for parsing ^ 1错误 我正在使用org.json,我想我已经正确设置了所有内容.我正在尝试使用org.json中的构造函数创建一个JSONObject,它接受一个源字符串,并且我一直得到这个异常.我不确定我发送的字符串有什么问题.谢谢
通过创建try和catch来捕获您的异常
try { JSONObject jsonObj = new JSONObject("{"count":3939,}]}"); System.out.println(jsonObj); } catch (JSONException e) { //some exception handler code. } 或者要么将您的例外用于调用方法. public String yourMethod(String jsonString) throws JSONException (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |