Package com.fasterxml.jackson.databind

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


      }
      else {
        JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(
            outputStream, JsonEncoding.UTF8);
        if (jsonView == null) {
          objectMapper.writeValue(jsonGenerator, responseObject);
        }
        else {
          objectMapper.writerWithView(jsonView).writeValue(jsonGenerator,
              responseObject);
        }
View Full Code Here


              System.out.print(new String(arg0, arg1, arg2));
              tmp.write(arg0, arg1, arg2);
            }
          };
        }
        objectMapper.writeValue(actualResponse, tracker.getQueue());
      }
     
    } catch(ProxyTypeSerialisationException e) {
      log.fatal("Unable to serialise type information to client: " + e.getMessage(), e);
     
View Full Code Here

      handleException(response, objectMapper, e);
     
    } catch(Exception e) {
      log.error("Exception during callback: " + e.getMessage(), e);
      tracker.getQueue().queueCommand(CommandType.EXCEPTION, null, null, new ExceptionDetails(e.getClass().getName(), e.getMessage()));
      objectMapper.writeValue(response, tracker.getQueue());
     
    } finally {
      s_currentHandler.set(null);
    }
  }
View Full Code Here

    protected void writeProfileRequirements(ProjectRequirements requirements, File profileBuildDir) throws IOException {
        ObjectMapper mapper = DtoHelper.getMapper();
        String name = DtoHelper.getRequirementsConfigFileName(requirements);
        File outFile = new File(profileBuildDir, name);
        outFile.getParentFile().mkdirs();
        mapper.writeValue(outFile, requirements);
        getLog().info("Writing " + outFile);
    }

    protected void generateFabricAgentProperties(ProjectRequirements requirements, File file) throws MojoExecutionException, IOException {
        file.getParentFile().mkdirs();
View Full Code Here

        }
      } else if (annotations.getAnnotation(Jackson.class) != null) {
        try {
          ObjectMapper mapper = new ObjectMapper();
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
          mapper.writeValue(buffer, object);
          data = buffer.toByteArray();
        }
        catch (IOException e) {
          throw new UnsupportedOperationException("handle me gracefully", e);
        }
View Full Code Here

    // [Issue#6], missing overrides for File-backed generator
    public void testWriteToFile() throws Exception
    {
        ObjectMapper mapper = new XmlMapper();
        File f = File.createTempFile("test", ".tst");
        mapper.writeValue(f, new IntWrapper(42));

        String xml = readAll(f).trim();

        assertEquals("<IntWrapper><i>42</i></IntWrapper>", xml);
        f.delete();
View Full Code Here

      ObjectMapper mapper = new ObjectMapper();

      try {
         
        //POJO to JSON
      mapper.writeValue(new File("article.json"), createArticle());
      System.out.println("json created!");

      //JSON to POJO
      Article article = mapper.readValue(new File("article.json"), Article.class);
View Full Code Here

      List<Article> articles = new LinkedList<Article>();

      articles.add(createArticle());
      articles.add(createArticle());

      mapper.writeValue(new File("articles.json"), articles);
     
      //( 1 ) Collection<Map>
      List result = mapper.readValue(new File("articles.json"), List.class);
      System.out.println(result.get(0).getClass());
      System.out.println(result);
View Full Code Here

   
    // 3. Convert List<FileMeta> into JSON format
      ObjectMapper mapper = new ObjectMapper();
     
      // 4. Send resutl to client
      mapper.writeValue(response.getOutputStream(), files);
 
  }
  /***************************************************
   * URL: /upload?f=value
   * doGet(): get file of index "f" from List<FileMeta> as an attachment
View Full Code Here

     
      // 5. Add article to List<Article>
    articles.add(article);

    // 6. Send List<Article> as JSON to client
      mapper.writeValue(response.getOutputStream(), articles);
  }
}
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.