{
"icon": "service",
"title": "A",
"type": "service",
"children": [
{
"icon": "sharedlibraries",
"title": "sharedlibraries",
"type": "sharedlibraries",
"children": [
{
"icon": "war",
"title": "abc.war ( ui-shared-lib )",
"path": "abc/common/Services/1.2.0/lib/comp.war",
"reference": >"abc/common/templates/applications/11.1.2.3.jar/config/config.xml",
"type": "sharedlibrary",
"version": "11.1.2.0@11.1.2.0",
"children": [
{
"icon": "jar",
"title": "comp1.jar",
"path": >"abc/common/SharedServices/1.2.0/lib/comp.war/WEB-INF/lib/comp.jar",
"reference": >"abc/common/Services/1.2.0/lib/comp.war/WEB-INF/lib",
"type": "jar",
"thirdpartyjar": "true"
}
]
},
:
:
:
}
I would need to retrieve, attribute "path", of all nodes with name "children", whose "thirdpartyjar" atribute= true. Is this possible using jackson?
Update: I tried following:
public void parse(File file) throws JsonProcessingException,
IOException {
ObjectMapper objectMapper = new ObjectMapper();
//JsonNode rootNode = objectMapper.readTree(file);
Model model = objectMapper.readValue(file, Model.class);
listThirdPartyJars(model);
while (true) {
Model children = model.getChildren();
if (!(children == null)) {
listThirdPartyJars(children);
model = children;
} else {
break;
}
}
}
public void listThirdPartyJars(Model model) {
boolean thirdPartyJars = model.isThirdPartyJar();
if (thirdPartyJars == true)
System.out.println(model.getPath());
}
But, came across following exception: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.manager.Model out of START_ARRAY token at [Source: D:\my_json.json; line: 4, column: 22] (through reference chain: com.manager.Model["children"])