本文介绍了JSONObject文本必须在1 [字符2第1行]处以'{'开头,错误为'{'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4";
JSONObject jsonObject = new JSONObject(JSON);
JSONObject getSth = jsonObject.getJSONObject("get");
Object level = getSth.get("2");
System.out.println(level);
我提到了许多解析此链接的解决方案,同样的问题.有谁能给我一个解析它的简单解决方案.
I referred many solutions for parsing this link, still getting the same error in question.Can any give me a simple solution for parsing it.
推荐答案
您的问题是String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4";
不是JSON
.
您想要做的是打开一个与" http://www的HTTP
连接. .json-generator.com/j/cglqaRcMSW?indent = 4 ",然后解析JSON 响应.
Your problem is that String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4";
is not JSON
.
What you want to do is open an HTTP
connection to "http://www.json-generator.com/j/cglqaRcMSW?indent=4" and parse the JSON response.
String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4";
JSONObject jsonObject = new JSONObject(JSON); // <-- Problem here!
将不会打开与站点的连接并检索内容.
Will not open a connection to the site and retrieve the content.
这篇关于JSONObject文本必须在1 [字符2第1行]处以'{'开头,错误为'{'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!