List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:com.nirmata.workflow.details.JsonSerializer.java
public static ExecutableTask getExecutableTask(JsonNode node) { return new ExecutableTask(new RunId(node.get("runId").asText()), new TaskId(node.get("taskId").asText()), getTaskType(node.get("taskType")), getMap(node.get("metaData")), node.get("isExecutable").asBoolean()); }
From source file:org.eel.kitchen.jsonschema.ref.JsonPointerTest.java
private static Object[] mungeArguments(final JsonNode node) { final Message.Builder msg = Domain.REF_RESOLVING.newMessage().setKeyword("$ref") .setMessage("illegal JSON Pointer"); final Map<String, JsonNode> map = JacksonUtils.nodeToMap(node.get("info")); for (final Map.Entry<String, JsonNode> entry : map.entrySet()) msg.addInfo(entry.getKey(), entry.getValue()); return new Object[] { node.get("input").textValue(), msg.build() }; }
From source file:bear.plugins.nodejs.NodeJsPlugin.java
private static String getString(JsonNode node, String field, String _default) { JsonNode name = node.get(field); if (name != null) return name.asText(); return _default; }
From source file:com.twosigma.beakerx.table.serializer.TableDisplayDeSerializer.java
@SuppressWarnings("unchecked") public static List<String> getClasses(JsonNode n, ObjectMapper mapper) throws IOException { List<String> classes = null; if (n.has("types")) classes = mapper.readValue(n.get("types").toString(), List.class); return classes; }
From source file:com.github.arnebinder.hide.swagger.params.HiderMojo.java
public static JsonNode merge(JsonNode mainNode, JsonNode updateNode) throws MojoExecutionException { if (updateNode instanceof ArrayNode) { if (!(mainNode instanceof ArrayNode)) { // error throw new MojoExecutionException( "Could not merge nodes: " + mainNode.toString() + " is not an ArrayNode."); } else {//from w ww . ja va 2 s . com Iterator<JsonNode> updateElements = updateNode.elements(); while (updateElements.hasNext()) { JsonNode updateElement = updateElements.next(); if (updateElement.has("name") && updateElement.get("name") != null && updateElement.get("name").isTextual()) { String updateName = updateElement.get("name").asText(); JsonNode mNode = mainNode.findValue(updateName); if (mNode == null) { // add updateElement to mainNode ((ArrayNode) mainNode).add(updateElement); } merge(mNode, updateElement); } else { throw new MojoExecutionException("Could not find key \"name\" in ArrayNode update element: " + updateElement.toString()); } } } } else { Iterator<String> fieldNames = updateNode.fieldNames(); while (fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode jsonNode = mainNode.get(fieldName); // if field exists and is an embedded object if (jsonNode != null && jsonNode.isObject()) { merge(jsonNode, updateNode.get(fieldName)); } else { if (mainNode instanceof ObjectNode) { // Overwrite field JsonNode value = updateNode.get(fieldName); ((ObjectNode) mainNode).replace(fieldName, value); } } } } return mainNode; }
From source file:org.glowroot.tests.WebDriverIT.java
private static void resetRoles() throws Exception { String content = httpGet("http://localhost:" + getUiPort() + "/backend/admin/roles"); ArrayNode roles = (ArrayNode) new ObjectMapper().readTree(content); for (JsonNode role : roles) { String name = role.get("name").asText(); if (name.equalsIgnoreCase("Administrator")) { continue; }// w w w. j a v a2s . com httpPost("http://localhost:" + getUiPort() + "/backend/admin/roles/remove", "{\"name\":\"" + name + "\"}"); } }
From source file:com.twosigma.beakerx.table.serializer.TableDisplayDeSerializer.java
@SuppressWarnings("unchecked") public static List<String> getColumns(JsonNode n, ObjectMapper mapper) throws IOException { List<String> columns = null; if (n.has("columnNames")) columns = mapper.readValue(n.get("columnNames").toString(), List.class); return columns; }
From source file:org.glowroot.tests.WebDriverIT.java
private static void deleteAllAlerts() throws Exception { String content = httpGet(/* w w w . j a v a2 s . c o m*/ "http://localhost:" + getUiPort() + "/backend/config/alerts?agent-rollup-id=" + agentId); ArrayNode alerts = (ArrayNode) new ObjectMapper().readTree(content).get("alerts"); for (JsonNode alert : alerts) { String version = alert.get("version").asText(); httpPost("http://localhost:" + getUiPort() + "/backend/config/alerts/remove?agent-rollup-id=" + agentId, "{\"version\":\"" + version + "\"}"); } }
From source file:org.glowroot.tests.WebDriverIT.java
private static void resetUsers() throws Exception { String content = httpGet("http://localhost:" + getUiPort() + "/backend/admin/users"); ArrayNode users = (ArrayNode) new ObjectMapper().readTree(content); for (JsonNode user : users) { String username = user.get("username").asText(); if (username.equalsIgnoreCase("anonymous")) { continue; }/* w w w. j a va 2s .c o m*/ httpPost("http://localhost:" + getUiPort() + "/backend/admin/users/remove", "{\"username\":\"" + username + "\"}"); } }
From source file:org.glowroot.tests.WebDriverIT.java
private static void deleteAllGauges() throws Exception { String content = httpGet("http://localhost:" + getUiPort() + "/backend/config/gauges?agent-id=" + agentId); ArrayNode gauges = (ArrayNode) new ObjectMapper().readTree(content); for (JsonNode gauge : gauges) { String name = gauge.get("config").get("mbeanObjectName").asText(); if (name.equals("java.lang:type=Memory") || name.equals("java.lang:type=GarbageCollector,name=*") || name.equals("java.lang:type=MemoryPool,name=*") || name.equals("java.lang:type=OperatingSystem")) { continue; }/* ww w . ja va 2 s . c om*/ String version = gauge.get("config").get("version").asText(); httpPost("http://localhost:" + getUiPort() + "/backend/config/gauges/remove?agent-id=" + agentId, "{\"version\":\"" + version + "\"}"); } }