如何从json对象内的多个json数组获取字符串 [英] How to get string from multiple json array inside a json object

查看:160
本文介绍了如何从json对象内的多个json数组获取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{ 数据:" { 日历": [ { 已预订":["2015年11月13日","2015年12月12日"], 可用":["2015年12月20日","2015年12月22日"] } ] } }

{ "data:" { "calendar": [ { "Booked":["13-11-2015","12-12-2015"], "Available":["20-12-2015","22-12-2015"] } ] } }

任何人都可以帮助我如何从json数组字符串获取日期

Could any one please help me how to get date from json array string

推荐答案

您的json应该是这样的

Your json should be like this

{
"data":{
"calendar":[
{
"Booked":[
"13-11-2015",
"12-12-2015"
],
"Available":[
"20-12-2015",
"22-12-2015"
]
}   ]    }    }

您可以使用 json在线解析器来检查json的有效性.

You can use json online parser to check the validity of a json.

现在,回到您的实际问题.我没有android IDE,因此我将发布一个快速代码给您一个想法

Now, coming back to your actual question.I dont have an android IDE so I will post a quick code to give u an idea

JSONObject jparentobj= new JSONObect("jsonString");

JSONObject datajObj= jparentobj.getJSONObect("data");

JSONArray calenderarray = datajObj.getJSONArray{"calender"};

for (int i=0;i<calenderarray .size(0;i++){
String booked=calenderarray .get(i).getString("Booked");
//Like this get each entity

}

希望这对您有所帮助.

这篇关于如何从json对象内的多个json数组获取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆