public static String dumpConfigurationAsJson() {
   ImmutableCollection<String> keys = CONFIGURATION_SECTIONS.keySet();
   ObjectMapper mapper = new ObjectMapper();
   JsonFactory jfactory = mapper.getJsonFactory();
   StringWriter sw = new StringWriter();
   try {
     JsonGenerator gen = jfactory.createJsonGenerator(sw);
     gen.writeStartArray();
     for (String v : keys) {
       String st = dumpConfigurationAsJson(v);
       ObjectMapper op = new ObjectMapper();
       JsonNode p = op.readTree(st);
       Logger.debug("OBJECT:" + p.toString());
       Logger.debug("STRING:" + st);
       // JsonParser jp = jfactory.createJsonParser(st);
       gen.writeTree(p);
     }
     gen.writeEndArray();
     gen.close();
     return sw.toString();
   } catch (Exception e) {
     Logger.error("Cannot generate a json for the configuration", e);
   }
   return "[]";
 } // dumpConfigurationAsJson()
Ejemplo n.º 2
0
 public void setSource(TreeNode tree) throws IOException {
   JsonFactory jsonFactory = new JsonFactory();
   if (buffer == null) {
     buffer = Unpooled.buffer();
   } else {
     buffer.clear();
   }
   type = QueueMessageType.JSON;
   try (ByteBufOutputStream outputStream = new ByteBufOutputStream(buffer)) {
     JsonGenerator generator = jsonFactory.createGenerator(outputStream);
     generator.setCodec(new ObjectMapper());
     generator.writeTree(tree);
     generator.close();
   }
 }
Ejemplo n.º 3
0
 @Override
 public void serialize(JSONOptions value, JsonGenerator jgen, SerializerProvider provider)
     throws IOException, JsonGenerationException {
   jgen.writeTree(value.root);
 }