Package com.fasterxml.jackson.databind

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


        final ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
        builder.put("string1", "hello");
        builder.put("string2", "world");
        builder.put("string4", "again");

        final String csv = writer.writeValueAsString(builder.build());

        assertEquals("hello,world,,again\n", csv);
    }

    // [Issue#45]
View Full Code Here


        csvSchemaBuilder.addColumn("value", CsvSchema.ColumnType.NUMBER);
        csvSchemaBuilder.addColumn("id", CsvSchema.ColumnType.STRING);
        final CsvSchema schema = csvSchemaBuilder.build();
        final ObjectWriter writer = new CsvMapper().writer().withSchema(schema);

        final String string = writer.writeValueAsString(
                ImmutableMap.of("timestamp", 0L, "value", 42));
        assertEquals("0,42,\n", string);
    }
}
View Full Code Here

        String name = clazz.getName();
        try {
            ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
            JsonSchema jsonSchema = mapper.generateJsonSchema(clazz);
            customizeSchema(clazz, jsonSchema);
            return writer.writeValueAsString(jsonSchema);
//            SchemaFactoryWrapper schemaFactoryWrapper = new SchemaFactoryWrapper();
//            mapper.acceptJsonFormatVisitor(mapper.constructType(clazz), schemaFactoryWrapper);
//            com.fasterxml.jackson.module.jsonSchema.JsonSchema jsonSchema = schemaFactoryWrapper.finalSchema();
//            return writer.writeValueAsString(jsonSchema);
        } catch (Exception e) {
View Full Code Here

        } finally {
            System.err.println("So far -> ["+sw+"]");
        }
        */
       
        String xml = w.writeValueAsString(input);

//System.err.println("DEBUG: Xml == "+xml);

        ObjectReader r = MAPPER.reader(MediaItem.class);
        MediaItem result = r.readValue(xml);
View Full Code Here

          Adaptrex.get(context).getProperties().get(AdaptrexProperties.DEBUG));
    }
    ObjectMapper mapper = new ObjectMapper();
        if (debug) {
            ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
            return writer.writeValueAsString(object);
        } else {
            return mapper.writeValueAsString(object);
        }
    }
View Full Code Here

                                ImmutableMap.builder()
                                        .put("number", String.valueOf(i))
                                        .put("difference", diffSb.toString().replace("\"", "\\\"").replace("\n", "\\n"))
                                        .put("actual-path", difference.getLeftPath())
                                        .put("actual-keyOfInterest", actualKeyOfInterest)
                                        .put("actual-context", objectWriter.writeValueAsString(
                                            toContext(diff.getLeftAt(actualContextPath),
                                                        actualKeyOfInterest))
                                                    .replace("\"", "\\\"").replace("\n", "\\n"))
                                        .put("expected-path", difference.getRightPath())
                                        .put("expected-keyOfInterest", expectedKeyOfInterest)
View Full Code Here

                                            toContext(diff.getLeftAt(actualContextPath),
                                                        actualKeyOfInterest))
                                                    .replace("\"", "\\\"").replace("\n", "\\n"))
                                        .put("expected-path", difference.getRightPath())
                                        .put("expected-keyOfInterest", expectedKeyOfInterest)
                                        .put("expected-context", objectWriter.writeValueAsString(
                                            toContext(diff.getRightAt(expectedContextPath),
                                                    expectedKeyOfInterest))
                                                    .replace("\"", "\\\"").replace("\n", "\\n"))
                                .build()
                                );
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.