FasterXML / FasterXML/jackson-dataformats-text

Cannot deserialize YAML sets

Ouverte
#317 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
yaml
Langage dominant
Java
Étoiles
455
Forks
164
Merge moyen
6 j 10 h
PR mergées (30 j)
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<>() {});
}
}
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.