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

Bug deserializing Eclipse Collection's MutableMap. #43

Closed
motlin opened this issue Feb 24, 2019 · 2 comments
Closed

Bug deserializing Eclipse Collection's MutableMap. #43

motlin opened this issue Feb 24, 2019 · 2 comments

Comments

@motlin
Copy link

motlin commented Feb 24, 2019

First off, thank you very much to @yawkat and @cowtowncoder for adding support for Eclipse Collections. I'm trying to change some usages of Map to MutableMap in my DTOs and running into an exception.

I've included two tests below to show the issue. I'm not sure if it's the same as #40.

The java.util.Map test passes with no output. The MutableMap test throws:

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize Map key of type `java.lang.Boolean` from String "trueKey": not a valid representation, problem: (com.fasterxml.jackson.databind.exc.InvalidFormatException) Cannot deserialize Map key of type `java.lang.Boolean` from String "trueKey": value not 'true' or 'false'
 at [Source: (String)"{
  "string": "string",
  "map": {
    "trueKey": true,
    "falseKey": false
  }
}
"; line: 4, column: 16]
 at [Source: (String)"{
  "string": "string",
  "map": {
    "trueKey": true,
    "falseKey": false
  }
}
"; line: 4, column: 16] (through reference chain: com.example.JacksonEclipseCollectionsTest$HasMutableMap["map"])

In JacksonEclipseCollectionsTest.java:

package com.example;

import java.io.IOException;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
import org.eclipse.collections.api.map.MutableMap;
import org.junit.Test;

public class JacksonEclipseCollectionsTest
{
    //language=JSON
    private static final String JSON = ""
            + "{\n"
            + "  \"string\": \"string\",\n"
            + "  \"map\": {\n"
            + "    \"trueKey\": true,\n"
            + "    \"falseKey\": false\n"
            + "  }\n"
            + "}\n";

    private final ObjectMapper objectMapper = new ObjectMapper()
            .registerModule(new EclipseCollectionsModule());

    public static final class HasMutableMap
    {
        @JsonCreator
        public HasMutableMap(
                @JsonProperty("string") String string,
                @JsonProperty("map") MutableMap<String, Boolean> map) {}
    }

    public static final class HasRegularMap
    {
        @JsonCreator
        public HasRegularMap(
                @JsonProperty("string") String string,
                @JsonProperty("map") Map<String, Boolean> map) {}
    }

    @Test
    public void testMutableMap() throws IOException
    {
        this.objectMapper.readValue(JSON, HasMutableMap.class);
    }

    @Test
    public void testRegularMap() throws IOException
    {
        this.objectMapper.readValue(JSON, HasRegularMap.class);
    }
}
@yawkat
Copy link
Member

yawkat commented Feb 26, 2019

Thank you for the @-mention, I didn't follow issues :)

This looks to be the issue fixed in #39.

@motlin
Copy link
Author

motlin commented Mar 4, 2019

I guess I'm just waiting on a release then! Thanks.

@motlin motlin closed this as completed Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants