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

Serializing a map doesn't use serializers #42

Closed
dAti opened this Issue Sep 11, 2017 · 1 comment

Comments

Projects
None yet
4 participants
@dAti
Copy link

dAti commented Sep 11, 2017

When I have a map with a Date object it isn't serialized according to serializers and configuration eg

        Ghost ghost = new Ghost();
        ghost.setDateTime(LocalDateTime.now());

        Map<String, Object> properties = new HashMap<>();
        ghost.setProperties(properties);
        properties.put("testtest", LocalDateTime.now());

        JsonbConfig config = new JsonbConfig()
                .withDateFormat("yyyy", Locale.ENGLISH);

        Jsonb jsonb = JsonbBuilder.create(config);

        String json = jsonb.toJson(ghost);

        System.out.println(json);
        Pattern pattern = Pattern.compile("\\d+:\\d+:\\d+");
        Matcher hoursMatcher = pattern.matcher(json);
        Assert.assertFalse("Should not contain hours", hoursMatcher.find());

Returns this json:

{"dateTime":"2017","properties":{"testtest":"2017-09-11T15:44:34.979"}}

The first date is okay but the second one is not using the configured format ("yyyy").

You can find a working example here:

https://github.com/dAti/yassonkaput/tree/master/src/test/java

@ymajoros

This comment has been minimized.

Copy link

ymajoros commented Sep 22, 2017

Any idea when this will be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment