Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writeTree()


    try {
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      ObjectNode objectNode = objectMapper.readValue(json, ObjectNode.class);
      objectNode.put(fieldName, id);
      objectMapper.writeTree(jsonGenerator, objectNode);
      jsonGenerator.flush();
      jsonGenerator.close();
      return stringWriter.toString();
    } catch (Exception e) {
      log.error(e);
View Full Code Here


      JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));
      JsonNode jsonNode = objectMapper.readTree(jsonParser);
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      jsonGenerator.useDefaultPrettyPrinter();

      objectMapper.writeTree(jsonGenerator, jsonNode);

      jsonGenerator.flush();
      jsonGenerator.close();

      /*
 
View Full Code Here

            // Create pretty printer:
            JsonGenerator gen = fac.createJsonGenerator(out);
            gen.useDefaultPrettyPrinter();

            // Now write:
            mapper.writeTree(gen, node);
           
            gen.flush();
            gen.close();
            return out.toString();
        }
View Full Code Here

                    String jsonName = derriveName(next);
                    ObjectNode schemaNode = schema.getSchemaNode();
                    schemaNode.put("name", jsonName);
                   
                    CharArrayWriter writer = new CharArrayWriter();
                    mapper.writeTree(mapper.getJsonFactory().createJsonGenerator(writer), schemaNode);
                   
                    StreamResult sr = new StreamResult(writer);
                   
                   
                    sr.setSystemId(jsonName);
View Full Code Here

      JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));
      JsonNode jsonNode = objectMapper.readTree(jsonParser);
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      jsonGenerator.useDefaultPrettyPrinter();

      objectMapper.writeTree(jsonGenerator, jsonNode);

      jsonGenerator.flush();
      jsonGenerator.close();
    } catch (Throwable throwable) {
      // hmm, somewhat accidentally crashed?
View Full Code Here

    try {
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      ObjectNode objectNode = objectMapper.readValue(json, ObjectNode.class);
      objectNode.put(fieldName, nodeValue);
      objectMapper.writeTree(jsonGenerator, objectNode);
      jsonGenerator.flush();
      jsonGenerator.close();
      return stringWriter.toString();
    } catch (Exception e) {
      log.error(e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.