杰克逊,如何解析"嵌套JSON"并设置为POJO类
Sales.json
{
"data": {
"modified_by": "mat",
"name": "mak",
"net_total": 0,
"items": [
{
"owner": "shoaib shaikh",
"modified_by": "mat",
"doctype": "Item"
}
],
"owner": "shoaib shaikh",
"apply_discount_on": "tesla"
}
}
答案 0 :(得分:0)
然后描述您的销售课程
import com.fasterxml.jackson.databind.ObjectMapper;
...
ObjectMapper mapper = new ObjectMapper();
Sales staff = mapper.readValue(new File("D:\\staff.json"), Sales.class);
一些帮助链接:https://www.mkyong.com/java/jackson-2-convert-java-object-to-from-json/