ObjectNode root = mapper.readTree("location.json"); if (root.getNodeType() == JsonNodeType.ARRAY) { //Use a get and the JsonNode API to traverse the tree to generate List<Location> } else { //Use a get and the JsonNode API to traverse the tree to generate single Location or a one-element List<Location> }
public RefModel refModel(ObjectNode node, String location, ParseResult result) { RefModel output = new RefModel(); if(node.getNodeType().equals(JsonNodeType.OBJECT)) { String refValue = ((TextNode)node.get("$ref")).textValue(); output.set$ref(refValue); } else { result.invalidType(location, "$ref", "object", node); return null; } // extra keys Set<String> keys = getKeys(node); for(String key : keys) { if(!REF_MODEL_KEYS.contains(key)) { result.extra(location, key, node.get(key)); } } return output; }
if (itemsNode.getNodeType().equals(JsonNodeType.OBJECT)){ items.setItems(getSchema(itemsNode, location, result)); }else if (itemsNode.getNodeType().equals(JsonNodeType.ARRAY)){ for (JsonNode n : itemsNode) { if (n.isValueNode()) {
if (itemsNode.getNodeType().equals(JsonNodeType.OBJECT)){ items.setItems(getSchema(itemsNode, location, result)); }else if (itemsNode.getNodeType().equals(JsonNodeType.ARRAY)){ for (JsonNode n : itemsNode) { if (n.isValueNode()) {
if (itemsNode.getNodeType().equals(JsonNodeType.OBJECT)){ items.setItems(getSchema(itemsNode, location, result)); }else if (itemsNode.getNodeType().equals(JsonNodeType.ARRAY)){ for (JsonNode n : itemsNode) { if (n.isValueNode()) {