如何采取从JSON对象的数据...? [英] How to take data from json object...?

查看:141
本文介绍了如何采取从JSON对象的数据...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用JSON数据的工作。

I just start working with JSON data.

[[[170, "kod", 148, 13, "2011-07-11T03:33:57Z", 11.68, 10.0, 1310373205707,     "2939393939"]], [{"announcement": {"post_by": null, "created_at": "2010-09-04T09:59:12Z", "announcement_category": null, "updated_at": "2010-09-04T09:59:12Z", "valid_till": "2010-09-04T09:59:00Z", "priority": null, "id": 3, "condtions": "", "message": "hello"}}]]

我想获得:

[170, "kod", 148, 13, "2011-07-11T03:33:57Z", 11.68, 10.0, 1310373205707, "0976741509"]

[{"announcement": {"post_by": null, "created_at": "2010-09-04T09:59:12Z", "announcement_category": null, "updated_at": "2010-09-04T09:59:12Z", "valid_till": "2010-09-04T09:59:00Z", "priority": null, "id": 3, "condtions": "", "message": "hello"}}]

在字符串

任何想法?

推荐答案

有关JSON解析为Android / Java的现有的库

Existing libraries for parsing JSON for Android/Java

有是一个很好的答案,这张贴在这里:

There's an excellent answer to this posted here:

  • Sending and Parsing JSON in Android

我很惊讶这些都没有被提及:而是使用
  最基本的,而手工工艺与json.org的小包装,GSON
  和杰克逊是更方便使用。所以:

I am surprised these have not been mentioned: but instead of using bare-bones rather manual process with json.org's little package, GSon and Jackson are much more convenient to use. So:

  • GSON
  • Jackson

所以,你实际上可以绑定到自己的POJO,而不是一些半称职的树
  节点或列表和地图。 (至少杰克逊允许结合到这样
  事情太多(也许GSON为好,不知道),JsonNode,地图,列表中,如果
  你真的想这些,而不是真实的对象)

So you can actually bind to your own POJOs, not some half-assed tree nodes or Lists and Maps. (and at least Jackson allows binding to such things too (perhaps GSON as well, not sure), JsonNode, Map, List, if you really want these instead of 'real' objects)

这篇关于如何采取从JSON对象的数据...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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