使用JACKSON将JSON对象读入java

时间:2017-03-16 19:28:48

标签: java json jackson

我有一个json对象:

    {"Result":{"code":0,"description":"success"} ,
        "Tickets":[{
        "TicketDetails":[
                       {"Key":"tknum","Value":888},
                       {"Key":"tkDescription","Value":"test"},
                      ],
        "Requestor":[
                       {"Key":"name","Value":"abc"},
                       {"Key":"add","Value":"xyz"},
                      ]

      },
 {
     "TicketDetails":[
                       {"Key":"tknum","Value":333},
                       {"Key":"tkDescription","Value":"test1"},
                      ],
     "Requestor":[
                       {"Key":"name","Value":"abc2"},
                       {"Key":"add","Value":"xyz3"},
                      ]

      }

     ]
}

我不想使用JSON Parser。是否可以将此JSON直接读取到java pojo。 例如:

ObjectMapper mapper=new ObjectMapper();
TicketInfo info=mapper.readValue("above Json object",TicketInfo.class);

0 个答案:

没有答案