【问题标题】:How to get string from multiple json array inside a json object [duplicate]如何从json对象内的多个json数组中获取字符串[重复]
【发布时间】:2016-02-22 12:41:18
【问题描述】:

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

谁能帮我从json数组字符串中获取日期

【问题讨论】:

  • 这是一个无效的 json 数组

标签: android json


【解决方案1】:

你的json应该是这样的

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

您可以使用json online parser 来检查json的有效性。

现在,回到你的实际问题。我没有安卓 IDE,所以我会发布一个快速代码给你一个想法

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

}

希望对你有所帮助..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多