com.fasterxml.jackson.databind.JsonMappingException:无法从VALUE_NUMBER_INT标记中反序列化java.util.ArrayList的实例

时间:2017-11-01 06:33:33

标签: java json objectmapper

我正在尝试将String值加载到List的{​​{1}}中,以下是示例代码

Integers

当我运行上面的代码时,我正在关注import java.util.List; public class Test2 { private List<Integer> list; public List<Integer> getList() { return list; } public void setList(List<Integer> list) { this.list = list; } } import java.io.IOException; import java.util.List; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; public class Test { public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { ObjectMapper objectMapper = new ObjectMapper(); String s = "1 2 3"; //colorFrameAlertConfig.setColorNumber(objectMapper.readValue(configEntry.getValue(), List.class)); Test2 t = new Test2(); t.setList(objectMapper.readValue(s, List.class)); //getting exception here for(int i : t.getList()){ System.out.println(i); } } }

exception

1 个答案:

答案 0 :(得分:-1)