Answers for "java map to object"

1

map string string to java object

final ObjectMapper mapper = new ObjectMapper(); // jackson's objectmapper
final MyPojo pojo = mapper.convertValue(map, MyPojo.class);
Posted by: Guest on September-09-2020
0

map to object

let map = new Map();
map.set("a", 1);
map.set("b", 2);
map.set("c", 3);

let obj = Array.from(map).reduce((obj, [key, value]) => (
  Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't.
), {});

console.log(obj); // => { a: 1, b: 2, c: 3 }
Posted by: Guest on July-04-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language