Examples of writer()


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

        ObjectMapper mapper = new ObjectMapper();
        mapper.findAndRegisterModules();
       
        mapper.addMixInAnnotations(Object.class, PortletRenderExecutionEventFilterMixIn.class);
        final FilterProvider filterProvider = new SimpleFilterProvider().addFilter(PortletRenderExecutionEventFilterMixIn.FILTER_NAME, SimpleBeanPropertyFilter.filterOutAllExcept("fname", "executionTimeNano", "parameters"));
        final ObjectWriter portletEventWriter = mapper.writer(filterProvider);
       
        final String result = portletEventWriter.writeValueAsString(createEvent());
       
        assertEquals("{\"@c\":\".PortletRenderExecutionEvent\",\"fname\":\"fname1\",\"executionTimeNano\":123450000,\"parameters\":{}}", result);
    }
View Full Code Here

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

        //Clone from "shared" ObjectMapper
        mapper = mapper.copy();
       
        mapper.addMixInAnnotations(Object.class, PortletRenderExecutionEventFilterMixIn.class);
        final FilterProvider filterProvider = new SimpleFilterProvider().addFilter(PortletRenderExecutionEventFilterMixIn.FILTER_NAME, SimpleBeanPropertyFilter.filterOutAllExcept("fname", "executionTimeNano", "parameters"));
        final ObjectWriter portletEventWriter = mapper.writer(filterProvider);
       
        final String result = portletEventWriter.writeValueAsString(createEvent());
       
        assertEquals("{\"@c\":\".PortletRenderExecutionEvent\",\"fname\":\"fname1\",\"executionTimeNano\":123450000,\"parameters\":{}}", result);
    }
View Full Code Here

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

      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
      }
    }
View Full Code Here

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

    /**
     * Construct a MapBytesUtility.
     */
    private MapBytesUtility() {
      ObjectMapper mapper = new ObjectMapper();
      writer = mapper.writer();
      reader = mapper.reader(Map.class);
    }

    /**
     * Convert a map of string key/value pairs to a JSON string in a byte array.
View Full Code Here

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

        ObjectMapper mapper = new ObjectMapper().setDateFormat(new SimpleDateFormat(DATE_FORMAT));

        //Can also use annotations for this
        mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

        ObjectWriter writer = mapper.writer();

        Writer output = new StringWriter();

        try {
            writer.writeValue(output, object);
View Full Code Here

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

      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
      }
    }
View Full Code Here

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

      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
      }
    }
View Full Code Here

Examples of com.fasterxml.jackson.dataformat.csv.CsvMapper.writer()

    @Test
    public void testWrite_NullThirdColumn() throws JsonProcessingException
    {
        CsvMapper mapper = new CsvMapper();
        assertFalse(mapper.getFactory().isEnabled(CsvGenerator.Feature.OMIT_MISSING_TAIL_COLUMNS));
        String csv = mapper.writer().withSchema(SCHEMA).writeValueAsString(
                ImmutableMap.of("timestamp", "2014-03-10T23:32:47+00:00",
                        "value", 42));

        assertEquals("\"2014-03-10T23:32:47+00:00\",42,\n", csv);
        mapper.getFactory().enable(CsvGenerator.Feature.OMIT_MISSING_TAIL_COLUMNS);
View Full Code Here

Examples of com.fasterxml.jackson.dataformat.xml.XmlMapper.writer()

    // Test for ensuring that we can use ".withRootName()" to override
    // default name AND annotation
    public void testRenamedRootItem() throws Exception
    {
        XmlMapper xmlMapper = new XmlMapper();
        String xml = xmlMapper
                .writer()
                .withRootName("Shazam")
                .writeValueAsString(new SampleResource(123, "Foo", "Barfy!"))
                .trim();
        xml = removeSjsxpNamespace(xml);
View Full Code Here

Examples of com.google.caliper.runner.ServerSocketService.OpenedSocket.writer()

        new Runnable() {
          @Override public void run() {
            try {
              OpenedSocket openedSocket = worker.socketFuture().get();
              logger.fine("successfully opened the pipe from the worker");
              socketWriter = openedSocket.writer();
              runningReadStreams.addAndGet(1);
              openStreams.addAndGet(1);
              streamExecutor.submit(threadRenaming("worker-socket",
                  new StreamReader(openedSocket.reader())));
            } catch (ExecutionException 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.