Monday, 12 August 2013

How do I parse a json file into a hashmap in Android?

How do I parse a json file into a hashmap in Android?

Say I had this JSON object that I wanted to use in my Android application.
{
{
"1":"red",
"2":"blue",
"3":"green",
"4":"yellow"
}
}
My questions are:
How can I parse this json object in this HashMap?
private HashMap<Integer, String> map = new HashMap<Integer, String>();
Where would be the best place to store this json file in the android file
system? (in assets or values?)

No comments:

Post a Comment