How to dump null type with blank string ""

136 views
Skip to first unread message

sam

unread,
Dec 19, 2022, 4:35:08 AM12/19/22
to SnakeYAML
Hi, I want to dump null type with blank string "" instead of a "null" string. What should I do?

ideal
```
path:
```

get value when dump
```
path: null
```

sam

unread,
Dec 19, 2022, 4:39:15 AM12/19/22
to SnakeYAML
I found the reason why it output the "null" value because of this:

```java
org.yaml.snakeyaml.representer.SafeRepresenter

protected class RepresentNull implements Represent {

public Node representData(Object data) {
return representScalar(Tag.NULL, "null");
}
}
```

I think I can get the value by override this, is there a better way to solve it or config it by DumperOptions?
```
public Node representData(Object data) {
return representScalar(Tag.NULL, "");
}
```
Reply all
Reply to author
Forward
0 new messages