使用 jackson 删除 JSON 元素
我有一个特定的JSON Node,对应于import org.codehaus.jackson.JsonNode,而不是import org.codehaus.jackson.map.JsonNode。
[
{
"givenName": "Jim",
"formattedName": "jimJackson",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mr",
"honorificSuffix": "none"
},
{
"givenName": "john",
"formattedName": "johnLasher",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mr",
"honorificSuffix": "none"
},
{
"givenName": "carlos",
"formattedName": "carlosAddner",
"familyName": null,
"middleName": "none",
"honorifiPrefix": "mr",
"honorificSuffix": "none"
},
{
"givenName": "lisa",
"formattedName": "lisaRay",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mrs",
"honorificSuffix": "none"
},
{
"givenName": "bradshaw",
"formattedName": "bradshawLion",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mr",
"honorificSuffix": "none"
},
{
"givenName": "phill",
"formattedName": "phillKane",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mr",
"honorificSuffix": "none"
},
{
"givenName": "Gabriel",
"formattedName": "gabrielMoosa",
"familyName": null,
"middleName": "none",
"honorificPrefix": "mr",
"honorificSuffix": "none"
}
]
我想从上述数组的所有JSON节点中删除“familyName”和“middleName”。有没有办法做到这一点?