use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.
the class EnvironmentConfigSource method loadConfigData.
@Override
public ObjectNode loadConfigData(ObjectMapper objectMapper, FileSystemBinding fileSystemBinding) throws Exception {
ObjectNode rootNode = objectMapper.createObjectNode();
serverEnvironment.getenv().entrySet().stream().map(toPair()).flatMap(getFilterFunc()).map(getPairTokenizerFunc()).forEach(entry -> {
populate(rootNode, mapPathSegments(entry), 0, entry.getRight());
});
return rootNode;
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.
the class EnvironmentConfigSource method populate.
private void populate(ObjectNode node, List<String> path, int pathIndex, String value) {
String segment = path.get(pathIndex);
if (pathIndex == path.size() - 1) {
node.set(segment, TextNode.valueOf(value));
} else {
// For environment variables, we don't support array indexing.
// Thus, if there are remaining segments, it must mean that the parent is an object.
ObjectNode childNode = (ObjectNode) node.get(segment);
if (childNode == null) {
childNode = node.putObject(segment);
}
populate(childNode, path, pathIndex + 1, value);
}
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project ratpack by ratpack.
the class ObjectConfigSource method loadConfigData.
@Override
public ObjectNode loadConfigData(ObjectMapper mapper, FileSystemBinding fileSystemBinding) throws Exception {
JsonNode value = mapper.valueToTree(object);
ObjectNode root = mapper.createObjectNode();
String[] keys = path.split("\\.");
Iterator<String> iterator = Arrays.asList(keys).iterator();
ObjectNode node = root;
while (true) {
String key = iterator.next();
if (iterator.hasNext()) {
node = node.putObject(key);
} else {
node.set(key, value);
break;
}
}
return root;
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project spring-security-oauth by spring-projects.
the class FacebookController method photos.
@RequestMapping("/facebook/info")
public String photos(Model model) throws Exception {
ObjectNode result = facebookRestTemplate.getForObject("https://graph.facebook.com/me/friends", ObjectNode.class);
ArrayNode data = (ArrayNode) result.get("data");
ArrayList<String> friends = new ArrayList<String>();
for (JsonNode dataNode : data) {
friends.add(dataNode.get("name").asText());
}
model.addAttribute("friends", friends);
return "facebook";
}
use of com.fasterxml.jackson.databind.node.ObjectNode in project flink by apache.
the class JSONKeyValueDeserializationSchema method deserialize.
@Override
public ObjectNode deserialize(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException {
if (mapper == null) {
mapper = new ObjectMapper();
}
ObjectNode node = mapper.createObjectNode();
node.set("key", mapper.readValue(messageKey, JsonNode.class));
node.set("value", mapper.readValue(message, JsonNode.class));
if (includeMetadata) {
node.putObject("metadata").put("offset", offset).put("topic", topic).put("partition", partition);
}
return node;
}
Aggregations