List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:com.sinosoft.dtphone.rule.main.testJson.java
/** * @param args/*from w w w . j a va2 s . c o m*/ */ public static void main(String[] args) { // TODO Auto-generated method stub objectMapper = new ObjectMapper(); String body = null; RuleBean test = null; try { test = getTB(); jsonGenerator = objectMapper.getFactory().createJsonGenerator(System.out, JsonEncoding.UTF8); jsonGenerator.writeObject(test); // System.out.println(); // objectMapper.writeValue(System.out, test); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.oth.keycloak.CreateConfigSchema.java
public static void main(String[] args) { ObjectMapper mapper = new ObjectMapper(); try {/*from w ww. ja v a 2 s.co m*/ JsonSchema schema = mapper.generateJsonSchema(RealmsConfig.class); String s = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); System.out.println(s); } catch (Exception e) { e.printStackTrace(); } }
From source file:formats.db.fileformats.json.RunnerJSON.java
public static void main(String args[]) throws Exception { // Customers c = new Customers(3, "Anna", "Dovlat", 0, "?392819"); // JSONObject json = new JSONObject(); // json.put("id_cs", c.getId_cs()); // json.put("f_name", c.getF_name()); // json.put("l_name", c.getL_name()); // json.put("discount", c.getDiscount()); // json.put("license", c.getLicense()); // System.out.println(json.toJSONString()); // String jString = json.toJSONString(); ////from w w w. j av a 2s . c o m // ObjectMapper mapper = new ObjectMapper(); // Customers wasRead = mapper.readValue(jString, Customers.class); // System.out.println(wasRead); Customers customers = new Customers(4, "Olga", "Petrova", 1, "?378492"); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(new File("D:\\customers.json"), customers); }
From source file:com.sinosoft.dtphone.rule.main.testJson1.java
/** * @param args/* w w w .j a v a 2 s . c om*/ */ public static void main(String[] args) { objectMapper = new ObjectMapper(); RuleBean test = null; try { test = getTB(); jsonGenerator = objectMapper.getFactory().createJsonGenerator(System.out, JsonEncoding.UTF8); jsonGenerator.writeObject(test); // System.out.println(); // objectMapper.writeValue(System.out, test); } catch (IOException e) { e.printStackTrace(); } }
From source file:software.uncharted.Reindex.java
public static void main(String[] args) throws IOException { // Get all images JsonNode response = HTTPUtil.getJSON("http://localhost:3030/images/all"); final ObjectMapper mapper = new ObjectMapper(); // Create a list of post requests List<JsonNode> indexRequestBodies = JSONUtil.getStringList(response, "files").stream() .map(file -> "http://localhost:3030/image/" + file).map(url -> "{\"url\":\"" + url + "\"}") .map(json -> {//from w w w .j a v a2 s. c o m try { return mapper.readTree(json); } catch (IOException e) { } return null; }).filter(Objects::nonNull).collect(Collectors.toList()); // Reindex each for (JsonNode body : indexRequestBodies) { System.out.println("Indexing " + body.get("url").asText()); HTTPUtil.post("http://localhost:8080/index", body); } }
From source file:de.phoenix.submissionpipeline.Core.java
public static void main(String[] args) { ObjectMapper mapper = new ObjectMapper(); SubmissionTask task;//from ww w . ja va2s . c om try { task = mapper.readValue(System.in, SubmissionTask.class); } catch (Exception e) { e.printStackTrace(); return; } try { CompileTask compileTask = new CompileTask(task); CharSequenceCompiler<Object> compiler = compileTask.compile(); if (task.getTests().isEmpty()) { writeResult(mapper, new PhoenixSubmissionResult(SubmissionStatus.COMPILED, "Everything fine!")); return; } JUnitTask testTask = new JUnitTask(compiler, task); PhoenixSubmissionResult result = testTask.run(); writeResult(mapper, result); } catch (UserSubmissionException e) { writeResult(mapper, new PhoenixSubmissionResult(SubmissionStatus.ERROR, e.getMessage())); } }
From source file:de.softwareforge.streamery.StreameryMain.java
public static final void main(String... args) throws Exception { final ObjectMapper mapper = new ObjectMapper(); final DBI h2Dbi = getH2Dbi(); setupData(h2Dbi);/* w ww. j ava 2 s . c om*/ mapper.enable(SerializationFeature.INDENT_OUTPUT); Query<Data> q = h2Dbi.open().createQuery("SELECT * FROM data").setFetchSize(200).map(DataMapper.INSTANCE); final Observable<Data> observable = JdbiObservable.from(q); observable.subscribe(new JsonStreamer<>(mapper.getFactory())); }
From source file:tests.JSONOutput.java
public static void main(String[] main) throws IOException { ObjectMapper mapper = new ObjectMapper(); File file = new File("./examples/"); if (!file.exists()) { file.mkdir();/*w w w .j a va 2 s. co m*/ } { Keyspace k = new Keyspace("DDD"); mapper.writeValue(new File("./examples/keyspace.json"), k); { Table t = new Table(k, "tableName", "pk", "pkt"); t.addColumn(new Column("columnName", "columnType")); mapper.writeValue(new File("./examples/table.json"), t); } { Table t = new Table(); t.setKeyspace(k); t.setName("tableName"); TableQuery query = new TableQuery(); query.setTable(t); query.setCondition("WHERE name='bob' AND score >= 40"); mapper.writeValue(new File("./examples/query.json"), query); } } }
From source file:org.test.beans.JsonBeanTest.java
public static void main(String[] arg) throws IOException { System.out.println("Application Started"); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); UserMaster um = mapper.readValue(userMasterJson, UserMaster.class); System.out.println(um);// w w w . ja v a 2 s . co m UserTrans ut = mapper.readValue(userTransJson, UserTrans.class); System.out.println(ut); UserTrans utn = mapper.readValue(userTransJsonMore, UserTrans.class); System.out.println(utn); System.out.println(mapper.writeValueAsString(ut)); }
From source file:com.endava.webfundamentals.Main.java
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { HttpClient httpClient = HttpClientBuilder.create().build(); HttpGet httpRequest = new HttpGet("http://petstore.swagger.wordnik.com/api/api-docs"); HttpResponse httpResponse = httpClient.execute(httpRequest); ObjectMapper objectMapper = new ObjectMapper(); PetStore petStore = objectMapper.readValue(httpResponse.getEntity().getContent(), PetStore.class); PrintWriter out = new PrintWriter("PetStore.html"); out.println("<html>"); out.println("<header>"); out.println(petStore.getInfo().getTitle()); out.println("</header>"); out.println("<body>"); out.println("Api Version " + petStore.getApiVersion()); out.println("Swagger Version " + petStore.getSwaggerVersion()); out.println("<p>"); out.println(petStore.getInfo().getDescription()); out.println("</p>"); out.println("<p>"); out.println(petStore.getInfo().getContact()); out.println("</p>"); out.println(petStore.getInfo().getLicense()); out.println(petStore.getInfo().getLicenseUrl()); out.println("<p>"); out.println(petStore.getInfo().getTermsOfServiceUrl()); out.println("</p>"); out.println("</body>"); out.println("</html>"); out.close();//from w ww . j a v a 2s. c o m }