将mapdifference转换为jsonnode

问题描述 投票:0回答:1

我正在比较两个 json 文档,并使用 mapdifference 来获取两者的差异。 现在我想将这个差异修补到现有的 json,但返回的差异是在表单中

/applicant/0/EmployDetail/0/AnnualSalary: 99999868.99
/Notes/0/customNote: OM Application Notes

等等。

使用以下内容来生成差异:

MapDifference<String, Object> difference = Maps.difference(leftFlatMap, rightFlatMap);
difference.entriesOnlyOnRight().forEach((key, value) -> System.out.println(key + ": " + value));

我希望它将它转换为 jsonnode。

java guava jsonnode
1个回答
0
投票
JsonNode jsonDifference = new ObjectMapper().valueToTree(difference.entriesOnlyOnRight());
© www.soinside.com 2019 - 2024. All rights reserved.