我的json响应如下:
cmrun.out
模特课:
{"IsValid":false,"ModelErrors":null,"ValidationErrors":[10000]}
Object Mapper代码:
public class ShipmentResponse {
private boolean isValid;
private ModelErrors modelErrors;
private List<Integer> validationErrors = null;
我无法在解析之后将 validationErrors 从json映射到java,即validationErrors = null。我期待validationErrors = {1000}但不确定为什么?我知道我们可以使用TypeReference返回数组或列表但不嵌套在数据对象中。
答案 0 :(得分:1)
试试这个
object DepType extends App{
println("bla")
def feedExplicitInstance[AnimalInstance]
(animal:AnimalTypeClass[AnimalInstance])(food:animal.FoodThatAnimalLikes) = {
animal.feed(food)
}
// Does not compile:
def feedImplicitInstance[AnimalInstance,Food](food:Food)
(implicit animal:AnimalTypeClass[AnimalInstance],aux:Cat.Aux[Food,AnimalInstance]) = {
animal.feed(food)
// Error:(17, 17) type mismatch;
// found : food.type (with underlying type Food)
// required: animal.FoodThatAnimalLikes
// animal.feed(food)
}
feedExplicitInstance(Cat.CatInstance)(new CatFood())
}
trait Food{
def eat():Unit
}
trait AnimalTypeClass [AnimalInstance] {
type FoodThatAnimalLikes <: Food
def feed(f:FoodThatAnimalLikes)=f.eat()
}
trait Cat
class CatFood extends Food{
override def eat(): Unit = println("meow")
}
object Cat {
type Aux[Food,Animal]= AnimalTypeClass[Animal] {type FoodThatAnimalLikes = Food}
implicit object CatInstance extends AnimalTypeClass[Cat]{
override type FoodThatAnimalLikes = CatFood
}
}
一般来说,你的房产名称和实际的json(案件事宜)
都有错配