Deserialize JSON to classes

前端 未结 2 1316
抹茶落季
抹茶落季 2021-02-01 07:41

Server returns such part of JSON:

{\"condition\": {
    \"or\": [
        {
            \"and\": [
                {
                    \"operand\": \"a\",
             


        
2条回答
  •  执笔经年
    2021-02-01 08:26

    You should use a class, not an interface. Otherwise, Jackson cannot create an instance.

    I believe you also need to create default (aka no-arg) constructors for your POJOs for Jackson to work.

    Also, a good general approach for creating a Jackson mapping is to instantiate a Java instance of your classes and then create the JSON from that, Java -> JSON. This makes it much easier to understand how the mapping is different - going from JSON -> Java is harder to debug.

提交回复
热议问题