使用自定义的API [英] Using a custom API

查看:94
本文介绍了使用自定义的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的的Andr​​oid系统。 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:

  1. 异步HTTP客户端
  2. 凌​​空
  1. Asynchronous Http Client
  2. 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:

  1. 杰克逊
  2. GSON
  1. Jackson
  2. Gson

此链接了很好的链接 GSON 教程。

我亲自使用 GSON ,它是 JSON 最好的图书馆,以 Java对象的转换。

I personally used GSON, and it is best library for json to java object conversion.

这篇关于使用自定义的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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