Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot deserialize YAML sets #317

Open
FichteFoll opened this issue Jun 29, 2022 · 0 comments
Open

Cannot deserialize YAML sets #317

FichteFoll opened this issue Jun 29, 2022 · 0 comments
Labels
yaml Issue related to YAML format backend

Comments

@FichteFoll
Copy link

FichteFoll commented Jun 29, 2022

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<java.lang.String>` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (BufferedReader); line: 2, column: 4] (through reference chain: java.util.LinkedHashMap["A"])

YAML source:

# block-style mapping (=set)
A: !!set
  ? A:A
  ? A:B

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

Simplified test code:

    public Map<String, Set<String>> readConfig(Path path) throws IOException {
        var yamlMapper = new ObjectMapper(new YAMLFactory());
        try (var reader = Files.newBufferedReader(path)) {
            return yamlMapper.readValue(reader, new TypeReference<>() {});
        }
    }
@cowtowncoder cowtowncoder added the yaml Issue related to YAML format backend label Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
yaml Issue related to YAML format backend
Projects
None yet
Development

No branches or pull requests

2 participants