I need to pass values from a json file to a java class,the json file is like this exemple:
{
"id":1,
"name":"Gold",
"description":"Shiny!",
"spriteId":1,
"consumable":true,
"effectsId":[1]
},
i need to map,i did this:
Items i = new Items();
Map<String, Items> mapaNomes = new HashMap<String, Items>();
mapaNomes.put("Gold",i);
mapaNomes.put("Apple",i );
mapaNomes.put("Clain Mail",i );
I'm new to android Development and I'm probably forgetting something because the following is not working,someone can help in find what`s is wrong?
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Gson gson = new Gson();
Items Items = gson.fromJson((BufferedReader) mapaNomes, Items.class);
Mapto aBufferedReaderwhich has nothing to do with the json?DataObject obj = gson.fromJson(br, DataObject.class);first convert your json reponse to DataObject and then map it. herebrisBufferedReaderobject