mardi 24 février 2015

Reading json file with gson package



I have the following json as my input:



{
"info":
{
"test2":{"key1":"val1","key2":"val2","key3":"val3"},
"test0":{"key1":"val1","key2":"val2","key3":"val3"},
"test1":{"key1":"val1","key2":"val2","key3":"val3"}
}
}


I believe the following class is compatible with the above json file:



public class ProfessionAuthor {
public Map<String, Map<String, String>> info = new HashMap<String, Map<String, String>>();
}


I read the json file with the following command:



Gson gson = new Gson();
Profession profession = gson.fromJson(reader, Profession.class);


But I get the the following error. Any idea?



jsonreader Expected a name but was BEGIN_OBJECT at



Aucun commentaire:

Enregistrer un commentaire