Examples of writeValueAsBytes()


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

    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

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

    // [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

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

        // 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

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

                                    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

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

                        try
                        {
                            stmt2.setString(1, configuredObject.getType());
                            if (configuredObject.getAttributes() != null)
                            {
                                byte[] attributesAsBytes = objectMapper.writeValueAsBytes(
                                        configuredObject.getAttributes());
                                ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                                stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
                            }
                            else
View Full Code Here

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

                                insertStmt.setNull(3, Types.BLOB);
                            }
                            else
                            {
                                final Map<String, Object> attributes = configuredObject.getAttributes();
                                byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);
                                ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                                insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                            }
                            insertStmt.execute();
                        }
View Full Code Here

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

            try
            {
                for(Map.Entry<UUID, Map<String,Object>> bindingEntry : bindingsToUpdate.entrySet())
                {
                    stmt.setString(1, "Binding");
                    byte[] attributesAsBytes = objectMapper.writeValueAsBytes(bindingEntry.getValue());

                    ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                    stmt.setBinaryStream(2, bis, attributesAsBytes.length);
                    stmt.setString(3, bindingEntry.getKey().toString());
                    stmt.execute();
View Full Code Here

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

                        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

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

                    try
                    {
                        stmt2.setString(1, configuredObject.getType());
                        if (configuredObject.getAttributes() != null)
                        {
                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(
                                    configuredObject.getAttributes());
                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                            stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
                        }
                        else
View Full Code Here

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

                            insertStmt.setNull(3, Types.BLOB);
                        }
                        else
                        {
                            final Map<String, Object> attributes = configuredObject.getAttributes();
                            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.