Package com.fasterxml.jackson.databind

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


   *
   * @throws java.io.IOException If something goes wrong
   */
  public static String jsonFixture(String fixtureClasspath) throws IOException {
    ObjectMapper om = new ObjectMapper();
    return om.writeValueAsString(om.readValue(fixture(fixtureClasspath), JsonNode.class));
  }

  /**
   * @param fixtureClasspath The classpath (can be in other JARs)
   *
 
View Full Code Here


    assertNotNull(socketSupport);

    SimpleTestRequest req = new SimpleTestRequest();
    ObjectMapper objectMapper = new ObjectMapper();

    String content = objectMapper.writeValueAsString(req);

    Map<String, String> headers = new HashMap<String, String>();
    headers.put("type", "SimpleTestRequest");
    MindRpcMessageHolder holder = new MindRpcMessageHolder(headers, content);
    clientRequestChannel.send(MessageBuilder.withPayload(holder).build());
View Full Code Here

    }

    public boolean savePreferences(String username, Map<String, Object> preferences) {
        try {
            ObjectMapper m = new ObjectMapper();
            final String body = m.writeValueAsString(preferences);
            api.path(resource.savePreferences(username)).body(new ApiRequest() {
                public String toJson() {
                    return body;
                }
            }).expect(Http.Status.NO_CONTENT).execute();
View Full Code Here

  //

  public String marshal(T object, boolean formatted) throws JsonProcessingException, IOException {
    ObjectMapper mapper = JsonHelper.buildObjectMapper(null, formatted);

    return mapper.writeValueAsString(object);
  }

  // public void marshal(T object, boolean formatted, OutputStream outputStream) throws XMLStreamException,
  // JAXBException, TransformerException, JSONException {
  // Configuration writeConfig = new Configuration(xmlNamespaceToJsonPrefix);
View Full Code Here

                                   "\"stddev\":5.0}");

        final ObjectMapper fullMapper = new ObjectMapper().registerModule(
                new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, true, MetricFilter.ALL));

        assertThat(fullMapper.writeValueAsString(histogram))
                .isEqualTo("{" +
                                   "\"count\":1," +
                                   "\"max\":2," +
                                   "\"mean\":3.0," +
                                   "\"min\":4," +
View Full Code Here

                                   "\"rate_units\":\"calls/second\"}");

        final ObjectMapper fullMapper = new ObjectMapper().registerModule(
                new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, true, MetricFilter.ALL));

        assertThat(fullMapper.writeValueAsString(timer))
                .isEqualTo("{" +
                                   "\"count\":1," +
                                   "\"max\":100.0," +
                                   "\"mean\":200.0," +
                                   "\"min\":300.0," +
View Full Code Here

                    NativeObject nativeObject = (NativeObject) result;
                    String js = nativeObject.get("js").toString();
                    String sourceMap;
                    try {
                        ObjectMapper objectMapper = new ObjectMapper();
                        sourceMap = objectMapper.writeValueAsString(nativeObject.get("v3SourceMap"));
                    } catch (Exception e) {
                        sourceMap = null;
                    }

                    return new CompileResult(js, sourceMap);
View Full Code Here

   *
   * @throws IOException If something goes wrong
   */
  public static String jsonFixture(String fixtureClasspath) throws IOException {
    ObjectMapper om = new ObjectMapper();
    return om.writeValueAsString(om.readValue(fixture(fixtureClasspath), JsonNode.class));
  }

  /**
   * @param fixtureClasspath The classpath (can be in other JARs)
   *
 
View Full Code Here

        // this is fine:
        boolean can = mapper.canSerialize(Simple.class);
        assertTrue(can);

        // but with problem of [JACKSON-540], we get nasty surprise here...
        String json = mapper.writeValueAsString(s);
       
        Simple result = mapper.readValue(json, Simple.class);
        assertNotNull(result.list);
        assertEquals(2, result.list.size());
    }
View Full Code Here

    @Test
    public void testJsonIoContainer() throws IOException {
        ObjectMapper objectMapper = new Log4jJsonObjectMapper();
        Fixture expected = new Fixture();
        final String s = objectMapper.writeValueAsString(expected);
        Fixture actual = objectMapper.readValue(s, Fixture.class);
        assertEquals(expected.proxy.getName(), actual.proxy.getName());
        assertEquals(expected.proxy.getMessage(), actual.proxy.getMessage());
        assertEquals(expected.proxy.getLocalizedMessage(), actual.proxy.getLocalizedMessage());
        assertEquals(expected.proxy.getCommonElementCount(), actual.proxy.getCommonElementCount());
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.