我应该使用XML或JSON作为Android应用程序的数据格式? [英] Should I use XML or JSON as a data format in Android Applications?

查看:111
本文介绍了我应该使用XML或JSON作为Android应用程序的数据格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始开发谷歌Android的应用程序,并严重依赖于网络的API,可通过JSON或XML提供一个宁静的方式的数据。我现在必须决定选择哪一个库。

I'm starting to develop an application for Google Android and heavily relying on a web API that can deliver data in a restful way via json or xml. I now have to decide which library to choose.

我看到了谷歌包括org.json类的API中,但还没有测试他们没有。

I saw that google includes org.json classes in the API but haven't tested them yet.

是您的经验如何?什么库/ API应该使用,为什么?

How are your experiences? What library/API should I use and why?

推荐答案

如果你主要是瞄准了一个内部​​的API,它仅仅是你控制的服务器和您要创建一个客户之间的联系,我会强烈建议JSON - 这是迄今为止在大多数情况下更简洁,从而减少所需的数据传输

If you're mostly aiming for an internal API that is simply a link between servers you control and a client you're creating, I'd highly recommend JSON - it's far more concise in most cases, thus minimizing the data transfer necessary.

解析JSON与org.json是那么简单的传递JSON字符串的的JSONObject构造,然后用在你的每一个期望的属性相应类型得到-的方法。

Parsing JSON with org.json is as straightforward as passing the JSON string to the constructor of JSONObject, and then using the appropriate type get-methods on each of your expected attributes.

这篇关于我应该使用XML或JSON作为Android应用程序的数据格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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