Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writeValueAsBytes()


                                                       HttpResponseStatus.OK);
    sourcesResp.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
    sourcesResp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
    ObjectMapper objMapper = new ObjectMapper();
    HttpChunk body =
        new DefaultHttpChunk(ChannelBuffers.wrappedBuffer(objMapper.writeValueAsBytes(String.valueOf(startScn))));
    NettyTestUtils.sendServerResponses(_dummyServer, clientAddr, sourcesResp, body);
  }

  static class DummyDatabusBootstrapConnectionStateMessage implements DatabusBootstrapConnectionStateMessage
  {
View Full Code Here


    public static final String REQUEST_PARAMETER_USERNAME = "username";

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }
}
View Full Code Here

    public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }
}
View Full Code Here

    public static final String REQUEST_PARAMETER_USERNAME = "username";

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }
}
View Full Code Here

        //  {"name":"test1","id":1,"nodes":[{"name":"test2","id":2},{"name":"test3","id":3}]}
        objectMapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);

        jsonObject = objectMapper.readValue(data, 0, data.length, JsonObject.class);

        return objectMapper.writeValueAsBytes(jsonObject);
    }

}
View Full Code Here

            user.setId(String.valueOf(idGenerator.incrementAndGet()));
        }

        entityManager.persist(user);

        return objectMapper.writeValueAsBytes(user);
    }

    public byte[] listUsers(byte[] req) throws IOException {
        ObjectMapper objectMapper = getJsonObjectMapper();
View Full Code Here

    public byte[] listUsers(byte[] req) throws IOException {
        ObjectMapper objectMapper = getJsonObjectMapper();

        List users = entityManager.createQuery("from User").getResultList();

        return objectMapper.writeValueAsBytes(users);
    }

}
View Full Code Here

    // [JACKSON-733]
    public void testBinary() throws IOException
    {
        byte[] input = new byte[] { 1, 2, 3, -1, 8, 0, 42 };
        ObjectMapper mapper = smileMapper();
        byte[] smile = mapper.writeValueAsBytes(new BytesBean(input));
        BytesBean result = mapper.readValue(smile, BytesBean.class);
       
        assertNotNull(result.bytes);
        Assert.assertArrayEquals(input, result.bytes);
    }
View Full Code Here

        // Ok: let's just do quick comparison (yes/no)...
        ObjectMapper plain = new ObjectMapper();
        ObjectMapper smiley = new ObjectMapper(f);
        String exp = plain.writeValueAsString(item);
        byte[] smile = smiley.writeValueAsBytes(item);
        MediaItem result = smiley.readValue(smile, 0, smile.length, MediaItem.class);
        String actual = plain.writeValueAsString(result);
        assertEquals(exp, actual);
    }
View Full Code Here

                                    else
                                    {
                                        final Map<String, Object> attributes = configuredObject.getAttributes();
                                        final ObjectMapper objectMapper = new ObjectMapper();
                                        objectMapper.registerModule(_module);
                                        byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);

                                        ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                                        insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                                    }
                                    insertStmt.execute();
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.