使用自定义的API [英] Using a custom API
问题描述
我刚开始使用的网站 http://www.kimonolabs.com ,并创造了一个API,因为我需要从我校网站上获取数据投入到学校的应用程序,我创造。不幸的是,我真的不提前计划,这使我对我两个问题:
I just started using the website http://www.kimonolabs.com and created an API as I need to retrieve data from my school website to put into the school app I am creating. Unfortunately, I do not really plan ahead, and this leads me to my 2 questions:
1)我怎么有这个API在我校Android应用程序?
1) How do I include this API in my school Android App?
2)如何解析JSON在这个API? (或者只是链接我到另一个页面上,这将是同样的极大AP preciated :))
2) How do I parse the JSON in this API? (Or just linking me to another page on this would be equally as greatly appreciated :) )
非常感谢任何帮助,您可以给!对不起,我的语言,我是14:P
Thanks very much for any help you can give! Sorry for my language, I am 14 :P
推荐答案
首先第一件事情。看看 AsyncTask的的Android系统。 AsyncTask的 <$ C C $>用于异步执行这些操作。看看这个答案解释如何参数传递到的AsyncTask
First things first. Take a look at AsyncTask in Android. AsyncTask
is used to perform operations asynchronously. Take a look at this answer explaining how parameters are passed to AsyncTask
.
您可以使用贝娄提到库去做同样的事情:
You can use libraries mentioned bellow to do same thing:
- Asynchronous Http Client
- Volley
在你与服务器进行通信并接收响应,你要分析 JSON
数据。
Once you communicate with server and receive response, you have to parse JSON
data.
您必须记住这个最关键的是
The key you have to remember for this is
[] - square bracket represents JSON Array
{} - curly bracket represents JSON Object
一切将是这些组合。
Everything else will be combination of these.
本教程将帮助您关于 JSON解析
。
JSON对象的Java对象转换
要转换 JSON
数据的Java
对象,你可以使用:
To convert json
data to java
object you can use:
- Jackson
- Gson
我亲自使用 GSON
,它是 JSON
最好的图书馆,以 Java对象
的转换。
I personally used GSON
, and it is best library for json
to java object
conversion.
这篇关于使用自定义的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!