Using a custom API

前端 未结 1 1962
悲哀的现实
悲哀的现实 2020-12-12 08:17

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. Unf

相关标签:
1条回答
  • 2020-12-12 08:38

    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. Asynchronous Http Client
    2. Volley

    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.

    This tutorial will help you regarding JSON parsing.

    JSON object to Java object conversion

    To convert json data to java object you can use:

    1. Jackson
    2. Gson

    Follow this link or this link for nice GSON tutorial.

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

    0 讨论(0)
提交回复
热议问题