本文整理汇总了Java中com.fasterxml.jackson.core.util.MinimalPrettyPrinter类的典型用法代码示例。如果您正苦于以下问题:Java MinimalPrettyPrinter类的具体用法?Java MinimalPrettyPrinter怎么用?Java MinimalPrettyPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinimalPrettyPrinter类属于com.fasterxml.jackson.core.util包,在下文中一共展示了MinimalPrettyPrinter类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSimpleDocWithMinimal
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@SuppressWarnings("resource")
public void testSimpleDocWithMinimal() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(ObjectWriteContext.empty(), sw);
// first with standard minimal
gen.setPrettyPrinter(new MinimalPrettyPrinter());
String docStr = _verifyPrettyPrinter(gen, sw);
// which should have no linefeeds, tabs
assertEquals(-1, docStr.indexOf('\n'));
assertEquals(-1, docStr.indexOf('\t'));
// And then with slightly customized variant
gen = new JsonFactory().createGenerator(ObjectWriteContext.empty(), sw);
gen.setPrettyPrinter(new MinimalPrettyPrinter() {
@Override
// use TAB between array values
public void beforeArrayValues(JsonGenerator jg) throws IOException, JsonGenerationException
{
jg.writeRaw("\t");
}
});
docStr = _verifyPrettyPrinter(gen, sw);
assertEquals(-1, docStr.indexOf('\n'));
assertTrue(docStr.indexOf('\t') >= 0);
gen.close();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:TestPrettyPrinter.java
示例2: testCustomSeparatorsWithMinimal
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
public void testCustomSeparatorsWithMinimal() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(ObjectWriteContext.empty(), sw);
gen.setPrettyPrinter(new MinimalPrettyPrinter().setSeparators(Separators.createDefaultInstance()
.withObjectFieldValueSeparator('=')
.withObjectEntrySeparator(';')
.withArrayValueSeparator('|')));
_writeTestDocument(gen);
gen.close();
assertEquals("[3|\"abc\"|[true]|{\"f\"=null;\"f2\"=null}]", sw.toString());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:TestPrettyPrinter.java
示例3: to
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@Override
public void to(final Writer out, final T object) {
try (StringWriter writer = new StringWriter()) {
this.objectMapper.writer(this.prettyPrinter).writeValue(writer, object);
if (isJsonFormat()) {
final Stringify opt = this.prettyPrinter instanceof MinimalPrettyPrinter ? Stringify.FORMATTED : Stringify.FORMATTED;
JsonValue.readHjson(writer.toString()).writeTo(out, opt);
} else {
IOUtils.write(writer.toString(), out);
}
} catch (final Exception e) {
throw new IllegalArgumentException(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:AbstractJacksonBackedStringSerializer.java
示例4: startPartition
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@Override
public void startPartition(WritePartition partition) throws Exception {
// close previous partition if open.
if(this.partition != null){
close();
}
this.partition = partition;
try {
this.fileName = fs.canonicalizePath(partition.qualified(location, prefix + "_0." + extension));
stream = fs.create(fileName);
JsonGenerator generator = factory.createGenerator(stream).useDefaultPrettyPrinter();
if (uglify) {
generator = generator.setPrettyPrinter(new MinimalPrettyPrinter(LINE_FEED));
}
if(useExtendedOutput){
gen = new ExtendedJsonOutput(generator);
}else{
gen = new BasicJsonOutput(generator);
}
logger.debug("Created file: {}", fileName);
} catch (IOException ex) {
throw UserException.dataWriteError(ex)
.message("Failure writing JSON file %s.", fileName)
.build(logger);
}
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:29,代码来源:JsonRecordWriter.java
示例5: BeanObjectJsonSerializer
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
/**
* Instantiates a new Bean object json serializer.
*/
public BeanObjectJsonSerializer() {
super(new MinimalPrettyPrinter());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:7,代码来源:InternalConfigStateController.java
示例6: initStructure
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@Nullable
private String initStructure(CanvasSessionData data, SelectionSession session, SingleSignonForm form)
{
final String courseId = data.getCourseId();
String structure = form.getStructure();
if( structure == null )
{
// if course ID is empty then there is nothing we can do...
if( Strings.isNullOrEmpty(courseId) )
{
throw new RuntimeException(LABEL_ERROR_NO_COURSE.getText());
}
structure = courseStructureCache.get(courseId).orNull();
}
// if no structure, get from Canvas
if( structure == null )
{
final ObjectNode root = objectMapper.createObjectNode();
root.put("id", courseId);
root.put("name", data.getContextTitle());
root.put("targetable", false);
final ArrayNode foldersNode = objectMapper.createArrayNode();
root.put("folders", foldersNode);
final Connector connector = findConnector(data);
final List<ConnectorFolder> folders = connectorRepoService.getFoldersForCourse(connector,
CurrentUser.getUsername(), courseId, false);
boolean first = true;
for( ConnectorFolder folder : folders )
{
final ObjectNode folderNode = objectMapper.createObjectNode();
folderNode.put("id", folder.getId());
folderNode.put("name", folder.getName());
folderNode.put("targetable", true);
folderNode.put("defaultFolder", first);
foldersNode.add(folderNode);
first = false;
}
final PrettyPrinter pp = new MinimalPrettyPrinter();
try
{
structure = objectMapper.writer().with(pp).writeValueAsString(root);
}
catch( JsonProcessingException e )
{
throw Throwables.propagate(e);
}
}
if( structure != null )
{
courseStructureCache.put(courseId, structure);
}
return structure;
}
开发者ID:equella,项目名称:Equella,代码行数:56,代码来源:CanvasIntegration.java
示例7: getStructure
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
private String getStructure(String courseId, String connectorUuid, String selected)
{
try
{
final boolean isDefaultApplicable = !Strings.isNullOrEmpty(selected);
final String cacheKey = connectorUuid + ":" + courseId + (!isDefaultApplicable ? "" : ":" + selected);
String structure = courseStructureCache.get(cacheKey).orNull();
// if no structure, get from Brightspace
if( structure == null )
{
final Connector connector = connectorService.getByUuid(connectorUuid);
if( connector == null )
{
throw new RuntimeException("No connector with UUID = " + connectorUuid);
}
final ConnectorCourse course = brightspaceService.getCourse(connector, courseId);
final ObjectNode root = objectMapper.createObjectNode();
root.put("id", courseId);
root.put("name", course.getName());
root.put("targetable", false);
final ArrayNode foldersNode = objectMapper.createArrayNode();
root.put("folders", foldersNode);
final List<ConnectorFolder> folders = brightspaceService.getFoldersForCourse(connector, null, courseId,
false);
boolean first = true;
for( ConnectorFolder folder : folders )
{
final ObjectNode folderNode = objectMapper.createObjectNode();
folderNode.put("id", folder.getId());
folderNode.put("name", folder.getName());
folderNode.put("targetable", true);
folderNode.put("selected",
(!isDefaultApplicable && first) || (isDefaultApplicable && selected.equals(folder.getId())));
foldersNode.add(folderNode);
first = false;
recurseFolder(connector, courseId, folder, folderNode, selected);
}
final PrettyPrinter pp = new MinimalPrettyPrinter();
try
{
structure = objectMapper.writer().with(pp).writeValueAsString(root);
}
catch( JsonProcessingException e )
{
throw Throwables.propagate(e);
}
if( structure == null )
{
// Can't happen
throw new RuntimeException("Could not create structure");
}
courseStructureCache.put(cacheKey, structure);
}
return structure;
}
catch( LmsUserNotFoundException lms )
{
throw Throwables.propagate(lms);
}
}
开发者ID:equella,项目名称:Equella,代码行数:69,代码来源:BrightspaceStructureInitServlet.java
示例8: BeanObjectJsonSerializer
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
/**
* Instantiates a new Bean object json serializer.
*/
BeanObjectJsonSerializer() {
super(new MinimalPrettyPrinter());
}
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:7,代码来源:InternalConfigStateController.java
示例9: init
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@Override
public void init(Map<String, String> writerOptions) throws IOException {
this.location = writerOptions.get("location");
this.prefix = writerOptions.get("prefix");
this.fieldDelimiter = writerOptions.get("separator");
this.extension = writerOptions.get("extension");
this.useExtendedOutput = Boolean.parseBoolean(writerOptions.get("extended"));
this.skipNullFields = Boolean.parseBoolean(writerOptions.get("skipnulls"));
final boolean uglify = Boolean.parseBoolean(writerOptions.get("uglify"));
Configuration conf = new Configuration();
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, writerOptions.get(FileSystem.FS_DEFAULT_NAME_KEY));
this.fs = FileSystem.get(conf);
Path fileName = new Path(location, prefix + "_" + index + "." + extension);
try {
// json writer does not support partitions, so only one file can be created
// and thus only one location should be deleted in case of abort
// to ensure that our writer was the first to create output file,
// we create empty output file first and fail if file exists
cleanUpLocation = storageStrategy.createFileAndApply(fs, fileName);
// since empty output file will be overwritten (some file systems may restrict append option)
// we need to re-apply file permission
stream = fs.create(fileName);
storageStrategy.applyToFile(fs, fileName);
JsonGenerator generator = factory.createGenerator(stream).useDefaultPrettyPrinter()
.configure(JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS,
!Boolean.parseBoolean(writerOptions.get("enableNanInf")));
if (uglify) {
generator = generator.setPrettyPrinter(new MinimalPrettyPrinter(LINE_FEED));
}
if(useExtendedOutput){
gen = new ExtendedJsonOutput(generator);
}else{
gen = new BasicJsonOutput(generator);
}
logger.debug("Created file: {}", fileName);
} catch (IOException ex) {
logger.error("Unable to create file: " + fileName, ex);
throw ex;
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:45,代码来源:JsonRecordWriter.java
示例10: JsonWriter
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
public JsonWriter(OutputStream os, Charset charset, ObjectMapper mapper) throws IOException {
generator = mapper.getFactory()
.createGenerator(new OutputStreamWriter(os, charset))
.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false)
.setPrettyPrinter(new MinimalPrettyPrinter(""));
}
开发者ID:trautonen,项目名称:logback-ext,代码行数:7,代码来源:JsonWriter.java
示例11: newCompactPrinter
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; //导入依赖的package包/类
@Override
protected PrettyPrinter newCompactPrinter() {
return new MinimalPrettyPrinter();
}
开发者ID:apache,项目名称:logging-log4j2,代码行数:5,代码来源:JacksonFactory.java
注:本文中的com.fasterxml.jackson.core.util.MinimalPrettyPrinter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论