-2

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) How do I include this API in my school Android App?

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 :) )

Thanks very much for any help you can give! Sorry for my language, I am 14 :P

planetastro
  • 1,716
  • 2
  • 15
  • 28
  • Very nice, first question did you know how to build android application. Creating api is great work just don't know what api does. Just make sure you have your problem statement and then start your work. – Codelord May 04 '15 at 08:30
  • You're learning so I'll point you in the right direction but it sounds like you need to do more research to get on the right track. If your API is sitting on an accessible server you would need to authenticate (if this is built into the API) and call your API endpoints (methods) via a HTTP request. There are libraries out there like http://loopj.com/android-async-http/ to help with this. There are also libraries to handle JSON data too. My advice: Have a look around to see what else you can find. – scgough May 04 '15 at 08:32
  • @Codelord Problem statement? – planetastro May 04 '15 at 08:38
  • @scgough Thanks! That is enough for me to start researching further. – planetastro May 04 '15 at 08:38
  • Problem Statement is what you want to achieve. Like create school management application. In this you divide your application in several parts, So each parts become your problem statements. – Codelord May 04 '15 at 08:40
  • Have a look at the Retrofit library for android it can parse REST api including json out of the box – Alexander Kulyakhtin May 04 '15 at 09:08

1 Answers1

-1

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.

Community
  • 1
  • 1
Paritosh
  • 2,097
  • 3
  • 30
  • 42