/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public JmxProcess parseProcess(File file) throws IOException { String fileName = file.getName(); ObjectMapper mapper = fileName.endsWith(".yml") || fileName.endsWith(".yaml") ? yamlMapper : jsonMapper; JsonNode jsonNode = mapper.readTree(file); JmxProcess jmx = mapper.treeToValue(jsonNode, JmxProcess.class); jmx.setName(fileName); return jmx; } }
/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public static JmxProcess getJmxProcess(File file) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); JmxProcess jmx = mapper.readValue(file, JmxProcess.class); jmx.setName(file.getName()); return jmx; }
/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public JmxProcess parseProcess(File file) throws IOException { String fileName = file.getName(); ObjectMapper mapper = fileName.endsWith(".yml") || fileName.endsWith(".yaml") ? yamlMapper : jsonMapper; JsonNode jsonNode = mapper.readTree(file); JmxProcess jmx = mapper.treeToValue(jsonNode, JmxProcess.class); jmx.setName(fileName); return jmx; } }
public static JmxProcess getJmxProcess(String name, InputStream in) throws JsonParseException, JsonMappingException, IOException { JmxProcess jmx = Json.readJsonValue(name, in, JmxProcess.class); jmx.setName(name); return jmx; }