FasterXML / FasterXML/jackson-dataformats-text

Cannot deserialize YAML sets

Open
#317 0 comments 0 reactions 0 assignees View on GitHub
yaml
Dominant language
Java
Stars
455
Forks
164
Avg merge
6d 10h
Merged PRs (30d)
2

Description

I was trying to deserialize a mapping of strings to sets and was met with the following error:

```
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.HashSet` from Object value (token `JsonToken.START_OBJECT`)
at [Source: (BufferedReader); line: 2, column: 4] (through reference chain: java.util.LinkedHashMap["A"])
```

YAML source:
```yaml
# block-style mapping (=set)
A: !!set
? A:A
? A:B

# flow mapping (=set)
B: !!set {B:A:, B:B:}
```

Simplified test code:
```java
public Map> readConfig(Path path) throws IOException {
var yamlMapper = new ObjectMapper(new YAMLFactory());
try (var reader = Files.newBufferedReader(path)) {
return yamlMapper.readValue(reader, new TypeReference<>() {});
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.