消费在Android上,最简单的方法REST服务?
问题描述:
我有一个REST服务,并希望与Android使用它。服务(JAX-RS)发布JSON数据。因此,主要问题有:
I have a REST Service and want to consume it with Android. The service (JAX-RS) publishes JSON data. So the main question are:
- 有什么好准备使用的解决方案为Android,如果没有,还能有什么建议?
- 我想传递的POJO,我怎么会知道呢?是GSON一个合适的方法?
感谢您
答
由于API级别8,你可以使用的 AndroidHTTPClient
或更早的API,您可以使用 DefaultHttpClient
,没有任何问题,并利用发送数据 HttpPost
或 HTTPGET
。对于 JSON
编码数据,是 GSON
是一个好方法,但我认为的 org.json
会比较容易上手。
Since API Level 8 you could use AndroidHTTPClient
, or for earlier APIs you can use DefaultHttpClient
with no problems, and send data using HttpPost
or HttpGet
. For encoding data in JSON
, yes GSON
is a good approach, but I think that org.json
would be more easy to use.