类com.fasterxml.jackson.core.PrettyPrinter源码实例Demo

下面列出了怎么用com.fasterxml.jackson.core.PrettyPrinter的API类实例代码及写法,或者点击链接到github查看源代码。

public static DataShape generateInspections(URL[] classpath, DataShape shape) throws IOException, ClassNotFoundException {
    JavaClass c = inspect(classpath, shape);

    List<DataShape> variants = new ArrayList<>(shape.getVariants().size());
    for (DataShape s : shape.getVariants()) {
        variants.add(generateInspections(classpath, s));
    }

    String inspection = io.atlasmap.v2.Json.mapper().writer((PrettyPrinter) null).writeValueAsString(c);
    return new DataShape.Builder()
        .createFrom(shape)
        .specification(inspection)
        .variants(variants)
        .compress()
        .build();
}
 
源代码2 项目: json-snapshot.github.io   文件: SnapshotMatcher.java
private static PrettyPrinter buildDefaultPrettyPrinter() {
  DefaultPrettyPrinter pp =
      new DefaultPrettyPrinter("") {
        @Override
        public DefaultPrettyPrinter withSeparators(Separators separators) {
          this._separators = separators;
          this._objectFieldValueSeparatorWithSpaces =
              separators.getObjectFieldValueSeparator() + " ";
          return this;
        }
      };
  Indenter lfOnlyIndenter = new DefaultIndenter("  ", "\n");
  pp.indentArraysWith(lfOnlyIndenter);
  pp.indentObjectsWith(lfOnlyIndenter);
  return pp;
}
 
源代码3 项目: logbook   文件: AutodetectPrettyPrintingMarker.java
@Override
protected void writeFieldValue(final JsonGenerator generator) throws IOException {
    final PrettyPrinter prettyPrinter = generator.getPrettyPrinter();

    if (prettyPrinter == null) {
        super.writeFieldValue(generator);
    } else {
        final JsonFactory factory = generator.getCodec().getFactory();

        // append to existing tree event by event
        try (final JsonParser parser = factory.createParser(super.getFieldValue().toString())) {
            while (parser.nextToken() != null) {
                generator.copyCurrentEvent(parser);
            }
        }
    }
}
 
源代码4 项目: pom-manipulation-ext   文件: JSONIO.java
public void writeJSON( File target, DocumentContext contents ) throws ManipulationException
{
    try
    {
        PrettyPrinter dpp = new MyPrettyPrinter( getCharset() );
        ObjectMapper mapper = new ObjectMapper();
        String jsonString = contents.jsonString();
        String pretty = mapper.writer( dpp ).writeValueAsString( mapper.readValue( jsonString, Object.class ) );
        Charset cs = getCharset();
        FileOutputStream fileOutputStream = new FileOutputStream( target );
        try (OutputStreamWriter p = new OutputStreamWriter( fileOutputStream, cs ) )
        {
            p.write( pretty );
            p.append( getEOL() );
        }
    }
    catch ( IOException e )
    {
        logger.error( "Unable to write JSON string:  ", e );
        throw new ManipulationException( "Unable to write JSON string", e );
    }
}
 
源代码5 项目: syndesis   文件: FhirMetadataRetrieval.java
static String includeResources(String specification, String... resourceTypes) throws IOException {
    if (resourceTypes != null && resourceTypes.length != 0) {
        XmlDocument document = MAPPER.readValue(specification, XmlDocument.class);
        includeResources(null, document, resourceTypes);
        return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document);
    }

    return specification;
}
 
源代码6 项目: json-snapshot.github.io   文件: SnapshotMatcher.java
static Function<Object, String> defaultJsonFunction() {

    ObjectMapper objectMapper = buildObjectMapper();

    PrettyPrinter pp = buildDefaultPrettyPrinter();

    return (object) -> {
      try {
        return objectMapper.writer(pp).writeValueAsString(object);
      } catch (Exception e) {
        throw new SnapshotMatchException(e.getMessage());
      }
    };
  }
 
private static PrettyPrinter initSsePrettyPrinter() {
	DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
	printer.indentObjectsWith(new DefaultIndenter("  ", "\ndata:"));
	return printer;
}
 
private static PrettyPrinter initSsePrettyPrinter() {
	DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
	printer.indentObjectsWith(new DefaultIndenter("  ", "\ndata:"));
	return printer;
}
 
源代码9 项目: summerframework   文件: JacksonFactory.java
@Override
protected PrettyPrinter newCompactPrinter() {
    return new MinimalPrettyPrinter();
}
 
源代码10 项目: summerframework   文件: JacksonFactory.java
@Override
protected PrettyPrinter newPrettyPrinter() {
    return new DefaultPrettyPrinter();
}
 
源代码11 项目: jfilter   文件: FilterObjectWriter.java
public ObjectWriter with(PrettyPrinter pp) {
    return new FilterObjectWriter(this, _config, _generatorSettings.with(pp), _prefetch);
}
 
源代码12 项目: curiostack   文件: JsonJacksonFactory.java
@Override
protected PrettyPrinter newCompactPrinter() {
  return new MinimalPrettyPrinter();
}
 
源代码13 项目: curiostack   文件: JsonJacksonFactory.java
@Override
protected PrettyPrinter newPrettyPrinter() {
  return new DefaultPrettyPrinter();
}
 
源代码14 项目: curiostack   文件: MessageMarshaller.java
private MessageMarshaller(@Nullable PrettyPrinter prettyPrinter, MarshallerRegistry registry) {
  this.prettyPrinter = prettyPrinter;
  this.registry = registry;
}
 
public ExtendedObjectWriter(ObjectMapper objectMapper, SerializationConfig config, JavaType rootType, PrettyPrinter pp) {
    super(objectMapper, config, rootType, pp);
}
 
public ObjectWriter _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp) {
    return new ExtendedObjectWriter(this, config, rootType, pp);
}
 
源代码17 项目: glowroot   文件: ObjectMappers.java
public static PrettyPrinter getPrettyPrinter() {
    CustomPrettyPrinter prettyPrinter = new CustomPrettyPrinter();
    prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
    return prettyPrinter;
}
 
源代码18 项目: logging-log4j2   文件: YamlJacksonFactory.java
@Override
protected PrettyPrinter newCompactPrinter() {
    return new MinimalPrettyPrinter();
}
 
源代码19 项目: logging-log4j2   文件: YamlJacksonFactory.java
@Override
protected PrettyPrinter newPrettyPrinter() {
    return new DefaultPrettyPrinter();
}
 
源代码20 项目: logging-log4j2   文件: XmlJacksonFactory.java
@Override
protected PrettyPrinter newCompactPrinter() {
    // Yes, null is the proper answer.
    return null;
}
 
源代码21 项目: logging-log4j2   文件: XmlJacksonFactory.java
@Override
protected PrettyPrinter newPrettyPrinter() {
    return new Log4jXmlPrettyPrinter(DEFAULT_INDENT);
}
 
源代码22 项目: logging-log4j2   文件: JsonJacksonFactory.java
@Override
protected PrettyPrinter newCompactPrinter() {
    return new MinimalPrettyPrinter();
}
 
源代码23 项目: logging-log4j2   文件: JsonJacksonFactory.java
@Override
protected PrettyPrinter newPrettyPrinter() {
    return new DefaultPrettyPrinter();
}
 
/**
 * Instantiates a new Registered service json serializer.
 *
 * @param prettyPrinter the pretty printer
 */
public AbstractJacksonBackedJsonSerializer(final PrettyPrinter prettyPrinter) {
    this.objectMapper = initializeObjectMapper();
    this.prettyPrinter = prettyPrinter;
}
 
/**
 * Instantiates a new Registered service json serializer.
 *
 * @param objectMapper  the object mapper
 * @param prettyPrinter the pretty printer
 */
public AbstractJacksonBackedJsonSerializer(final ObjectMapper objectMapper, final PrettyPrinter prettyPrinter) {
    this.objectMapper = objectMapper;
    this.prettyPrinter = prettyPrinter;
}
 
源代码26 项目: biweekly   文件: JCalRawWriter.java
/**
 * Sets the pretty printer to pretty-print the JSON with. Note that this
 * method implicitly enables indenting, so {@code setPrettyPrint(true)} does
 * not also need to be called.
 * @param prettyPrinter the custom pretty printer (defaults to an instance
 * of {@link JCalPrettyPrinter}, if {@code setPrettyPrint(true)} has been
 * called)
 */
public void setPrettyPrinter(PrettyPrinter prettyPrinter) {
	prettyPrint = true;
	this.prettyPrinter = prettyPrinter;
}
 
源代码27 项目: summerframework   文件: JacksonFactory.java
abstract protected PrettyPrinter newCompactPrinter(); 
源代码28 项目: summerframework   文件: JacksonFactory.java
abstract protected PrettyPrinter newPrettyPrinter(); 
源代码29 项目: curiostack   文件: AbstractJacksonFactory.java
protected abstract PrettyPrinter newCompactPrinter(); 
源代码30 项目: curiostack   文件: AbstractJacksonFactory.java
protected abstract PrettyPrinter newPrettyPrinter(); 
 同包方法