FasterXML / FasterXML/jackson-dataformats-text

Cannot deserialize YAML sets

Abierto
#317 0 comentarios 0 reacciones 0 asignados Ver en GitHub
yaml
Lenguaje dominante
Java
Estrellas
455
Forks
164
Merge medio
6 d 10 h
PR fusionados (30 d)
2

Descripción

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<>() {});
}
}
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.