JSON解析在java中 [英] Parsing JSON in java

查看:119
本文介绍了JSON解析在java中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解析JSON在Android的,但我有与访问对象的子儿的麻烦。我想提取以下扩充,

I'm trying to parse JSON in android but am having trouble with accessing sub children of an object. I am trying to extract augment from the following,

{"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"}
    ]
}}

我试图通过得到扩充列表命名扩充的JSON对象访问填充块,​​或增加[0],但不能弄清楚如何访问每个增强内。

I've tried accessing the augments by getting the JSON object of augment-list named augment, or augment[0] but cant figure it out how to access each augment inside.

推荐答案

如果没有什么错,我不能告诉什么问题可能会更加详细。您是否收到错误?你可以张贴一些code?

Without more detail of what's going wrong, I can't tell what the problem might be. Are you getting errors? Can you post some code?

你有这样的事?

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

这篇关于JSON解析在java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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