Search code examples
javajsonspringcontrollerdto

Spring does not convert JSON array to list in my DTO


Does Spring allow to convert list of elements from json to List<Long> in my dto? What I'm doing wrong? Hemp mw please to solve this problem.

https://i.sstatic.net/oWezk.png https://i.sstatic.net/PIG4x.png https://i.sstatic.net/3C4gu.png https://i.sstatic.net/evXIY.png

I tried everything just can't find the problem.


Solution

  • In the request body, you should not use kPartIds instead use kpartIds. When Lombok generates the get/set method it will change the first character to uppercase. Now the second character is also uppercase. So while converting JSON to object it will find both as lower character objects.

    {
        "title": "Test",
        "kpackIds": [5, 10]
    }
    

    Also as @user2131323 mentioned. Use actual code snippets instead of images.