org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class models.Job] from JSON String

后端 未结 2 1516
闹比i
闹比i 2021-01-13 04:13

i use the playframework and tried to deserialize some json into a java object. It worked fine, exept the relationship in the model. I got the following exception

2条回答
  •  走了就别回头了
    2021-01-13 04:52

    Either you change your JSON in order to describe your "job" entity :

    {
       "name":"asd",
       "filepath":"blob",
       "contenttype":"image/png",
       "description":"asd",
       "job":{
          "id":"1",
           "foo", "bar"
       }
    }
    

    or you create a constructor with a String parameter in your Job bean:

    public Job(String id) {
    // populate your job with its id
    }
    

提交回复
热议问题