I have a HashMap like so
Map<String , String>
when I get an element from the map by key it returns
["6"] I need only the 6 , not ["6"]
The value is added like so
map.put(k , jsonarray.toString()) ;
Thanks
Then you have 2 options change your map to
Map<String,Integer>
and then you'll need to put an int value inside
or when getting the value use:
Integer.valueOf(map.get("key"));
thats only valid in case your String inside the json is only an int - our you will get an exception!
You can use Integer#parseInt(String) to convert a String to an Integer
int value = Integer.parseInt(map.get("key"));
Change your Map to String and JsonArray and store JsonArray directly instead of converting it to String
Map<String , JsonArray>
Using your Map key, iterate your JsonArray object
JsonArray jsonArray;
Iterator<JsonElement> it = jsonArray.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
jsonarray.toString()sample ?