简体   繁体   English

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

[英]com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_NUMBER_INT token

I am trying to load a String value into List of Integers , here is the sample code 我正在尝试将String值加载到Integers List中,这是示例代码

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);
        }
  }

}

When I run the above code, I am getting following exception 当我运行上述代码时,出现以下exception

Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_NUMBER_INT token
at [Source: 1 2 3; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
at com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1234)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1122)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1075)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:338)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:269)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)
at com.sample.Test.main(Test.java:17)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.fasterxml.jackson.databind.JsonMappingException:无法从START_OBJECT令牌中反序列化java.util.ArrayList实例 - com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token com.fasterxml.jackson.databind.JsonMappingException:无法从START_ARRAY标记中反序列化TestAcceptanceCriteria的实例 - com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of TestAcceptanceCriteria out of START_ARRAY token com.fasterxml.jackson.databind.exc.MismatchedInputException:无法反序列化 START_OBJECT 令牌中的“java.util.ArrayList”实例 - com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token com.fasterxml.jackson.databind.JsonMappingException:无法从START_ARRAY令牌中反序列化org.springframework.data.domain.Sort的实例 - com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token 错误:com.fasterxml.jackson.databind.JsonMappingException:无法从START_ARRAY令牌中反序列化Entities.Student的实例 - Error: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of Entities.Student out of START_ARRAY token com.fasterxml.jackson.databind.JsonMappingException:无法反序列化START_ARRAY令牌 - com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token com.fasterxml.jackson.databind.JsonMappingException:数值超出范围的数值(1557587751202) - com.fasterxml.jackson.databind.JsonMappingException: Numeric value (1557587751202) out of range of int RestEasy:org.codehaus.jackson.map.JsonMappingException:无法从START_OBJECT标记(..)中反序列化java.util.ArrayList的实例 - RestEasy : org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token(..) Jackson无法从VALUE_STRING令牌中反序列化java.util.ArrayList的实例 - Jackson Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token com.fasterxml.jackson.databind.JsonMappingException 无法构造类的实例 - com.fasterxml.jackson.databind.JsonMappingException not able to construct instance of class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM