使用自定义的API

编程入门 行业动态 更新时间:2024-10-13 08:22:42
本文介绍了使用自定义的API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚开始使用的网站 www.kimonolabs ,并创造了一个API,因为我需要从我校网站上获取数据投入到学校的应用程序,我创造。不幸的是,我真的不提前计划,这使我对我两个问题:

I just started using the website www.kimonolabs 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的 用于异步执行这些操作。看看这个答案解释如何参数传递到的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:

  • 异步HTTP客户端
  • 凌​​空
  • 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:

  • 杰克逊
  • GSON
  • Jackson
  • Gson
  • 请此链接或了很好的链接 GSON 教程。

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

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

    更多推荐

    使用自定义的API

    本文发布于:2023-11-28 12:36:42,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1642425.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:自定义   API

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!