Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString()


    parser.setRegistry(new FunctionRegistry(DrillConfig.create()));
    parse_return ret = parser.parse();
    LogicalExpression e = ret.e;
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    System.out.println(mapper.writeValueAsString(e));

    // print the tree
    CommonTree tree = (CommonTree) ret.getTree();
    DOTTreeGenerator gen = new DOTTreeGenerator();
    StringTemplate st = gen.toDOT(tree);
View Full Code Here


    if(logger.isDebugEnabled()){
      JsonNode node;
      try {
        ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
        node = mapper.readValue(s, JsonNode.class);
        logger.debug("Optiq Generated Logical Plan: {}", mapper.writeValueAsString(node));
      } catch (IOException e) {
        logger.error("Failure while trying to parse logical plan string of {}", s, e);
      }
     
    }
View Full Code Here

        url.setMethod("GET");
        context.getUrls().add(url);
       
        ObjectMapper mapper = new ObjectMapper();
        try {
            String contextJson = mapper.writeValueAsString(context);
            model.addAttribute(ModelConstants.CONTEXT_JSON, contextJson);
        } catch (JsonGenerationException e) {
            logger.error(e.getMessage());
        } catch (JsonMappingException e) {
            logger.error(e.getMessage());
View Full Code Here

 
 
  public String toJSON(){
    ObjectMapper mapper = new ObjectMapper();
    try {
      return mapper.writeValueAsString(countries);
    } catch (JsonProcessingException e) {
      logger.warn(e.getMessage(), e);
    }
    return null;
  }
View Full Code Here

        url.setMethod("GET");
        context.getUrls().add(url);
       
        ObjectMapper mapper = new ObjectMapper();
        try {
            String contextJson = mapper.writeValueAsString(context);
            model.addAttribute(ModelConstants.CONTEXT_JSON, contextJson);
        } catch (JsonGenerationException e) {
            logger.error(e.getMessage());
        } catch (JsonMappingException e) {
            logger.error(e.getMessage());
View Full Code Here

      if (outputConfig.isDebug()) {
        configObjectString = mapper.writerWithDefaultPrettyPrinter()
            .writeValueAsString(modelObject);
      }
      else {
        configObjectString = mapper.writeValueAsString(modelObject);
      }

    }
    catch (JsonGenerationException e) {
      throw new RuntimeException(e);
View Full Code Here

    String configObjectString;
    try {
      if (debug) {
        configObjectString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(modelObject);
      } else {
        configObjectString = mapper.writeValueAsString(modelObject);
      }

    } catch (JsonGenerationException e) {
      throw new RuntimeException(e);
    } catch (JsonMappingException e) {
View Full Code Here

        return Ordering.natural().sortedCopy(issues);
    }

    private static String toJson(Commit commit) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(commit);
        return json;
    }
}
View Full Code Here

    public void testPropertyWithSubtypes() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        // must register subtypes
        mapper.registerSubtypes(SubB.class, SubC.class, SubD.class);
        String json = mapper.writeValueAsString(new PropertyBean(new SubC()));
        PropertyBean result = mapper.readValue(json, PropertyBean.class);
        assertSame(SubC.class, result.value.getClass());
    }

    // [JACKSON-748]: also works via modules
View Full Code Here

    {
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.registerSubtypes(SubB.class, SubC.class, SubD.class);
        mapper.registerModule(module);
        String json = mapper.writeValueAsString(new PropertyBean(new SubC()));
        PropertyBean result = mapper.readValue(json, PropertyBean.class);
        assertSame(SubC.class, result.value.getClass());
    }
   
    public void testSerialization() throws Exception
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.