-1

This is how my json file looks like:

{"GradeList": 
{"CODE":["012113001","00273011","040612003","090503012"],
"NAME":["Biology","Math","Physic","Reading I"],
"SECTION:["1","5","3","4"],
"GRADE":["B","A+","B+","B"}
}

I don't know how to read that data in my app.I can't change a data.

P CY
  • 1
  • 1
  • 1
    First of all ur JSON format is not correct,Try some online JSON formator for valid JSON format : https://www.jsoneditoronline.org/. – Haresh Chhelana Jun 24 '15 at 04:43
  • follow these tutorials :- 1) Normal JSON parsing- http://www.tutorialspoint.com/android/android_json_parser.htm http://www.androidhive.info/2012/01/android-json-parsing-tutorial/ http://www.vogella.com/tutorials/AndroidJSON/article.html 2) You can parse JSON with the GSON library too by creating simple DTO. You need to put gson jar in your libs folder for this. JSON parsing using GSON- http://examples.javacodegeeks.com/core-java/json/json-parsing-with-gson/ – Akanksha Rathore Jun 24 '15 at 04:56

1 Answers1

0

I would suggest to use Gson library.

Create new class:

public class GradeList {
    private Collection<String> CODE;
    private Collection<String> NAME;
    private Collection<String> SECTION;
    private Collection<String> GRADE;
}

Then:

Gson gson = new GsonBuilder().create();
    gson.fromJson(json, GradeList.class);

More information about GsonBuilder can be found here

madoxdev
  • 3,770
  • 1
  • 24
  • 39