FasterXML / FasterXML/jackson-dataformats-text

FeatureRequest: Add PRESERVE_COMMENTS feature for SnakeYAML > 2.0

オープン
#491 コメント 4 件 リアクション 4 件 担当者 0 名 GitHub で見る
yaml
主要言語
Java
スター
455
フォーク
164
平均マージ
6日 10時間
マージ済み PR(30日)
2

説明

Hi,

## Description

currently I am using Jackson with dataformat-yaml to sort my yaml files by key:

```
final YAMLFactory yamlFactory = new YAMLFactory()
.disable(YAMLGenerator.Feature.SPLIT_LINES)
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
;
this.objectMapper = new ObjectMapper(yamlFactory)
.registerModule(new Jdk8Module())
.setDefaultPrettyPrinter(new DefaultPrettyPrinter())
.configure(SerializationFeature.INDENT_OUTPUT, true)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, orderMapEntriesByKeys)
;
```

Now, comments will get lost regardless of which method I use to read and write the document.

## SnakeYAML features

However, with SnakeYAML alone you could do something like this:

1. Create a new Reader/Writer which preserves comments: https://stackoverflow.com/a/76975195/1549977
2. Create a custom Representer which sorts keys: https://stackoverflow.com/a/63095199/1549977

## Wishlist

Ideally, a comment above a key in the same indentation level stays with the key. If it is the same indentation level as the previous element, keep it below that one.

Can this be done in Jackson with dataformat-yaml?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。