Package org.codehaus.jackson.map

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


    // As per [JACKSON-683]: fail gracefully if super type not public
    public void testNonPublic() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new MrBeanModule());
        try {
            mapper.readValue("{\"x\":3}", NonPublicBean.class);
            fail("Should have thrown an exception");
        } catch (JsonMappingException e) {
            verifyException(e, "is not public");
View Full Code Here


    {
        try
        {
            StringWriter writer = new StringWriter();
            final ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.registerModule(_module);
            objectMapper.writeValue(writer, object.getAttributes());
            tupleOutput.writeString(object.getType());
            tupleOutput.writeString(writer.toString());
        }
        catch (JsonMappingException e)
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);
                                    }
View Full Code Here

                stmt.setString(1, configuredObject.getId().toString());
                ResultSet rs = stmt.executeQuery();
                try
                {
                    final ObjectMapper objectMapper = new ObjectMapper();
                    objectMapper.registerModule(_module);
                    if (rs.next())
                    {
                        PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
                        try
                        {
View Full Code Here

            }

            Map<UUID,Map<String,Object>> bindingsToUpdate = new HashMap<UUID, Map<String, Object>>();
            List<UUID> others = new ArrayList<UUID>();
            final ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.registerModule(_module);

            PreparedStatement stmt = connection.prepareStatement(SELECT_FROM_CONFIGURED_OBJECTS);
            try
            {
                try (ResultSet rs = stmt.executeQuery())
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);
                        }
View Full Code Here

            stmt.setString(1, configuredObject.getId().toString());
            ResultSet rs = stmt.executeQuery();
            try
            {
                final ObjectMapper objectMapper = new ObjectMapper();
                objectMapper.registerModule(_module);
                if (rs.next())
                {
                    PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
                    try
                    {
View Full Code Here

        // used aren't symmetric... but it works.
        final DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
        final ObjectMapper objectMapper = new ObjectMapper(null, null, deserializerProvider);
        final SimpleModule jsonModule = new SimpleModule("json", new Version(1, 0, 0, null));
        jsonModule.addSerializer(JsonRepresentation.class, new JsonRepresentationSerializer());
        objectMapper.registerModule(jsonModule);

        objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        return objectMapper;
    }
View Full Code Here

    {
        try
        {
            StringWriter writer = new StringWriter();
            final ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.registerModule(_module);
            objectMapper.writeValue(writer, object.getAttributes());
            tupleOutput.writeString(object.getType());
            tupleOutput.writeString(writer.toString());
        }
        catch (JsonMappingException e)
View Full Code Here

    protected DataWrapper convertJsonToDataWrapper(String json) {
        ObjectMapper mapper = new ObjectMapper();
        DataDTODeserializer dtoDeserializer = new DataDTODeserializer();
        SimpleModule module = new SimpleModule("DataDTODeserializerModule", new Version(1, 0, 0, null));
        module.addDeserializer(DataDTO.class, dtoDeserializer);
        mapper.registerModule(module);
        if (json == null || "[]".equals(json)){
            return null;
        }

        try {
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.