简体   繁体   中英

Iterate a String map and set in Bean

I have a Map of Strings like (["id":"1"]["name":"text"]["category":"mobile"]......) and I have a class to set all the key and values

class Test{
   private String id;
   private String name;
   private String category;
   public void setId(String id){
   }
   public void setName(String id){
   }
   public void setCategory(String id){
   }
}

The String map is having around 100 of keys like the above so is there a way to get from the map and set in the object through a iteration or I need to do it manually for all the keys?

Alternatively you could use the Map directly. For example: where ever you want to use id use map.get("id") instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM