java如何通过json读取嵌套的json对象
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
java如何通过json读取嵌套的json对象
"strs": [
{
"strs11": 111,
"strs12": 122,
"strs13": 133
{
"strs21": 211,
"strs22": 222,
"strs23": 233
}
],
"str2": 22,
"str3": 33,
"str4":44
URL url = new URL("http://localhost/test.jspx");
URLConnection urlconn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream(),"utf-8"));
String repStr = null;
if ((repStr = reader.readLine()) != null) {
JSONObject jObj = JSONObject.fromObject(repStr);
JSONArray jary=jObj.getJSONArray("strs");
for (int i=0;i<jary.size();i++) {
JSONObject obj = jary.getJSONObject(i);
String s2=obj.getString("strs11");
}
对象数据内容如下:
{
"str1": 11,"strs": [
{
"strs11": 111,
"strs12": 122,
"strs13": 133
{
"strs21": 211,
"strs22": 222,
"strs23": 233
}
],
"str2": 22,
"str3": 33,
"str4":44
}
URL url = new URL("http://localhost/test.jspx");
URLConnection urlconn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream(),"utf-8"));
String repStr = null;
if ((repStr = reader.readLine()) != null) {
JSONObject jObj = JSONObject.fromObject(repStr);
JSONArray jary=jObj.getJSONArray("strs");
for (int i=0;i<jary.size();i++) {
JSONObject obj = jary.getJSONObject(i);
String s2=obj.getString("strs11");
}
}
GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e
3 个月前
8c391e04
6 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)