慢慢更新
处理有时候是对象,有时候是[]的问题
这种情况常见于后端是PHP框架的时候,正常返回是对象,无数据时返回数组,这就要了亲命了,如果你用的是Jackson 那么只需配置DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT 就可将有些对象无数据时返回是[]的情况返回为null,这样就不会报错了。
参考 https://github.com/FasterXML/jackson-databind/wiki/Deserialization-Features
ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT ,true);