FasterXML / FasterXML/jackson-dataformats-text
FeatureRequest: Add PRESERVE_COMMENTS feature for SnakeYAML > 2.0
- Ngôn ngữ chính
- Java
- Star
- 455
- Fork
- 164
- Merge trung bình
- 6 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 2
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.