У меня есть строка json, как показано ниже
{
"haserrors":
{
"errornumber": "400",
"errors": [
{
"nameofbusiness-error-1": "nameofbusiness must have a length greater than 1",
"nameofbusiness-error-2": "legalname must have a length greater than 1",
"nameofbusiness-error-3": "postaladdress must have a length greater than 1",
"nameofbusiness-error-4": "city must have a length greater than 1",
"nameofbusiness-error-5": "state must have a length greater than 1",
"nameofbusiness-error-6": "pincode must have a length greater than 6, pincode must be numeric, pincode must be positive",
"nameofbusiness-error-7": "fewwords must have a length greater than 1",
"nameofbusiness-error-8": "lob must have a length greater than 1",
"nameofbusiness-error-9": "step must be numeric, step must be positive"
}
]
}
}
Мне нужно извлечь все узлы и значения в разделе «ошибки».Это мой текущий кусок кода
Configuration conf = Configuration.builder().jsonProvider(new JacksonJsonNodeJsonProvider())
.options(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS).build();
ArrayNode jsonErrorMessageNodes = JsonPath.using(conf).parse(<<JSON STRING ABOVE>>).read("$..errors");
for (Iterator<JsonNode> it = jsonErrorMessageNodes.elements() ; it.hasNext() ; ) {
JsonNode node = it.next();
String s = node.toString();
System.out.println(node);
}
Как мне получить имя узла?