FasterXML / FasterXML/jackson-dataformats-text

Jackson 3 parses YAML ~ as StringNode instead of NullNode

Đang mở
#661 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
yaml
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ả

In Jackson 2, the special character ~ was parsed as a NullNode, while in Jackson 3 I get a StringNode with value ~. It seems that the default behavior has changed.

I tried several YAML mapper configurations, but I couldn’t find any setting that reproduces the Jackson 2 behavior.

The issue can be reproduced with the following test:

```
@Test
void tilde() throws JsonProcessingException {
String rawDescriptor = """
specVersion: v1
kind: com.example.kind
name: "mnp_up"
state: ~
description: "a description"
""";

tools.jackson.dataformat.yaml.YAMLMapper myYamlMapper = new YAMLMapper();
JsonNode node1 = myYamlMapper.readValue(rawDescriptor, tools.jackson.databind.JsonNode.class);
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper(new YAMLFactory());
com.fasterxml.jackson.databind.JsonNode node2 = objectMapper.readValue(rawDescriptor, com.fasterxml.jackson.databind.JsonNode.class);
System.out.println("node1 state: " + node1.get("state").getNodeType() + "\nnode2 state: " + node2.get("state").getNodeType());
}
```
OUTPUT:
node1 state: STRING
node2 state: NULL

I couldn’t find anything about this in the migration documentation.

Since my application logic depends on parsing files that may contain this special character, I need to stay compatible with the behavior implemented in Jackson 2.

How can I configure the Jackson 3 mapper to get the same result as in Jackson 2?

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á.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.