【问题标题】:Parsing JSON in java在java中解析JSON
【发布时间】:2010-12-05 04:42:25
【问题描述】:

我正在尝试在 android 中解析 JSON,但无法访问对象的子子级。我正在尝试从以下内容中提取增强,

{"augment-list": {
  "time": "12:01",
  "channel": "channel1",
    "augment": [
      {"id": "123", "name": "here", "x": "5", "y": "10", "orientation": "up", "content": "some stuff"},
      {"id": "456", "name": "there", "x": "12", "y": "25", "orientation": "down", "content": "more stuff"},
      {"id": "789", "name": "over there", "x": "1", "y": "2", "orientation": "left", "content": "and more"}
    ]
}}

我尝试通过获取名为 augment 或 augment[0] 的增强列表的 JSON 对象来访问增强,但无法弄清楚如何访问内部的每个增强。

【问题讨论】:

    标签: java android json


    【解决方案1】:

    如果不详细说明问题所在,我无法判断问题可能是什么。你有错误吗?可以发一些代码吗?

    你有这样的东西吗?

    json.getJSONObject("augment-list").getJSONArray("augment").getJSONObject(0).getInt("id")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 2014-05-16
      • 2015-03-09
      • 2013-12-09
      • 1970-01-01
      相关资源
      最近更新 更多