我知道如何将一个简单的Java List
从Y
->;Z
,即:
List<String> x;
List<Integer> y = x.stream()
.map(s -> Integer.parseInt(s))
.collect(Collectors.toList());
现在我想对 map 做基本相同的操作,即:
INPUT:
{
"key1" -> "41", // "41" and "42"
"key2" -> "42" // are Strings
}
OUTPUT:
{
"key1" -> 41, // 41 and 42
"key2" -> 42 // are Integers
}
解决方案不应限于String
->;Integer
.就像上面的List
示例一样,我想调用任何方法(或构造函数).