Map JSON array of objects to @RequestBody List using jackson

前端 未结 3 1374
慢半拍i
慢半拍i 2020-12-13 14:36

I\'m having issues using Jackson to map a Javascript posted JSON array of hashes (Tag).


Here is the data received by the controller @RequestBody (It is send wit

3条回答
  •  旧时难觅i
    2020-12-13 15:34

    It sounds like Spring is not passing full type information for some reason, but rather a type-erased version, as if declaration was something like List tag. I don't know what can be done to fully resolve this (may need something from Spring integration team), but one work-around is to define your own type like:

    static class TagList extends ArrayList { }
    

    and use that instead. This will retain generic parameterization through super-type declarations so that even if Spring only passes equivalent of TagList.class, Jackson can figure out the Tag parameter.

提交回复
热议问题