Search in sources :

Example 6 with DefaultPrettyPrinter

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project jackson-core by FasterXML.

the class TestPrettyPrinter method testCustomSeparatorsWithPPWithoutSpaces.

public void testCustomSeparatorsWithPPWithoutSpaces() throws Exception {
    StringWriter sw = new StringWriter();
    JsonGenerator gen = new JsonFactory().createGenerator(ObjectWriteContext.empty(), sw);
    gen.setPrettyPrinter(new DefaultPrettyPrinter().withSeparators(Separators.createDefaultInstance().withObjectFieldValueSeparator('=').withObjectEntrySeparator(';').withArrayValueSeparator('|')).withoutSpacesInObjectEntries());
    _writeTestDocument(gen);
    gen.close();
    assertEquals("[ 3| \"abc\"| [ true ]| {" + DefaultIndenter.SYS_LF + "  \"f\"=null;" + DefaultIndenter.SYS_LF + "  \"f2\"=null" + DefaultIndenter.SYS_LF + "} ]", sw.toString());
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 7 with DefaultPrettyPrinter

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project jackson-core by FasterXML.

the class TestPrettyPrinter method testCustomSeparatorsWithPP.

public void testCustomSeparatorsWithPP() throws Exception {
    StringWriter sw = new StringWriter();
    JsonGenerator gen = new JsonFactory().createGenerator(ObjectWriteContext.empty(), sw);
    gen.setPrettyPrinter(new DefaultPrettyPrinter().withSeparators(Separators.createDefaultInstance().withObjectFieldValueSeparator('=').withObjectEntrySeparator(';').withArrayValueSeparator('|')));
    _writeTestDocument(gen);
    gen.close();
    assertEquals("[ 3| \"abc\"| [ true ]| {" + DefaultIndenter.SYS_LF + "  \"f\" = null;" + DefaultIndenter.SYS_LF + "  \"f2\" = null" + DefaultIndenter.SYS_LF + "} ]", sw.toString());
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 8 with DefaultPrettyPrinter

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project webprotege by protegeproject.

the class GetFormDescriptorActionHander method getDummy.

private GetFormDescriptorResult getDummy(CollectionId collectionId, FormId formId, CollectionItem elementId) {
    try {
        URL url = GetFormDescriptorActionHander.class.getResource("/amino-acid-form.json");
        System.out.println(url);
        InputStream is = GetFormDescriptorActionHander.class.getResourceAsStream("/amino-acid-form.json");
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addDeserializer(FormDataValue.class, new FormDataValueDeserializer(dataFactory));
        mapper.registerModule(module);
        mapper.setDefaultPrettyPrinter(new DefaultPrettyPrinter());
        FormDescriptor d = mapper.readerFor(FormDescriptor.class).readValue(new BufferedInputStream(is));
        is.close();
        CollectionItemData formData = repository.find(collectionId, elementId);
        return new GetFormDescriptorResult(projectId, collectionId, elementId, formId, d, formData.getFormData().orElse(FormData.empty()));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) CollectionItemData(edu.stanford.bmir.protege.web.shared.collection.CollectionItemData) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) URL(java.net.URL) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Example 9 with DefaultPrettyPrinter

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project rdf4j by eclipse.

the class RDFJSONWriter method modelToRdfJsonInternal.

public static void modelToRdfJsonInternal(final Model graph, final WriterConfig writerConfig, final JsonGenerator jg) throws IOException, JsonGenerationException {
    if (writerConfig.get(BasicWriterSettings.PRETTY_PRINT)) {
        // SES-2011: Always use \n for consistency
        Indenter indenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;
        // By default Jackson does not pretty print, so enable this unless
        // PRETTY_PRINT setting is disabled
        DefaultPrettyPrinter pp = new DefaultPrettyPrinter().withArrayIndenter(indenter).withObjectIndenter(indenter);
        jg.setPrettyPrinter(pp);
    }
    jg.writeStartObject();
    for (final Resource nextSubject : graph.subjects()) {
        jg.writeObjectFieldStart(RDFJSONWriter.resourceToString(nextSubject));
        for (final IRI nextPredicate : graph.filter(nextSubject, null, null).predicates()) {
            jg.writeArrayFieldStart(nextPredicate.stringValue());
            for (final Value nextObject : graph.filter(nextSubject, nextPredicate, null).objects()) {
                // contexts are optional, so this may return empty in some
                // scenarios depending on the interpretation of the way contexts
                // work
                final Set<Resource> contexts = graph.filter(nextSubject, nextPredicate, nextObject).contexts();
                RDFJSONWriter.writeObject(nextObject, contexts, jg);
            }
            jg.writeEndArray();
        }
        jg.writeEndObject();
    }
    jg.writeEndObject();
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) IRI(org.eclipse.rdf4j.model.IRI) Indenter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Indenter) DefaultIndenter(com.fasterxml.jackson.core.util.DefaultIndenter) Resource(org.eclipse.rdf4j.model.Resource) Value(org.eclipse.rdf4j.model.Value)

Example 10 with DefaultPrettyPrinter

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project solr-document-store by DBCDK.

the class SolrWorker method init.

@PostConstruct
public void init() {
    log.info("Initializing SolrWorker");
    onMessageTimer = registry.getRegistry().timer(MetricRegistry.name(SolrWorker.class, "onMessage"));
    solrDocStoreTimer = registry.getRegistry().timer(MetricRegistry.name(SolrWorker.class, "solrDocStore"));
    log.info("solrDocStoreUrl = {}", solrDocStoreUrl);
    this.client = HttpClientBuilder.create().build();
    this.printer = prettyPrintJson ? O.writer(new DefaultPrettyPrinter()) : O.writer();
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) PostConstruct(javax.annotation.PostConstruct)

Aggregations

DefaultPrettyPrinter (com.fasterxml.jackson.core.util.DefaultPrettyPrinter)42 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 IOException (java.io.IOException)9 File (java.io.File)7 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)6 DefaultIndenter (com.fasterxml.jackson.core.util.DefaultIndenter)6 OpenApiContext (io.swagger.v3.oas.integration.api.OpenApiContext)6 OpenAPI (io.swagger.v3.oas.models.OpenAPI)6 SwaggerConfiguration (io.swagger.v3.oas.integration.SwaggerConfiguration)4 PrettyPrinter (com.fasterxml.jackson.core.PrettyPrinter)3 JsonFactory (com.fasterxml.jackson.core.json.JsonFactory)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)3 OpenAPISpecFilter (io.swagger.v3.core.filter.OpenAPISpecFilter)3 SpecFilter (io.swagger.v3.core.filter.SpecFilter)3 OpenApiConfigurationException (io.swagger.v3.oas.integration.OpenApiConfigurationException)3 BufferedWriter (java.io.BufferedWriter)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3