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

Serializing a map doesn't use serializers #42

Closed
dAti-zz opened this issue Sep 11, 2017 · 1 comment
Closed

Serializing a map doesn't use serializers #42

dAti-zz opened this issue Sep 11, 2017 · 1 comment
Labels
bug Something isn't working right
Milestone

Comments

@dAti-zz
Copy link

dAti-zz 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

@m0mus m0mus added the bug Something isn't working right label Sep 12, 2017
@m0mus m0mus added this to the 1.0.1 milestone Sep 12, 2017
@m0mus m0mus closed this as completed in #46 Sep 16, 2017
@ymajoros
Copy link

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
Labels
bug Something isn't working right
Projects
None yet
Development

No branches or pull requests

4 participants