Skip to content

ObjectMapper configuration for json serialization #28

Description

@laurent-treeb

mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

I replace mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); with mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

I use my own http client with the mapper and the jeon model class
and with /_matrix/client/r0/keys/query, i had a bad request with NON_EMPTY because the serialization removes my empty list:

The Java object:

QueryRequest keysQuery = new QueryRequest(); keysQuery.setTimeout(5000L); Map<String, List<String>> devicesKeysRequest = new HashMap<>(); devicesKeysRequest.put(bobLogin.getUserId(), Collections.emptyList()); keysQuery.setDeviceKeys(devicesKeysRequest);

Serialized Json with NON_EMPTY => bad request:
{"timeout":5000}

Serialized Json with NON_NULL => good request:
{"timeout":5000,"device_keys":{"@a66bf63f-d9bc-41d1-99ce-467c2af61c26:matrix.docker.localhost":[]}}

In Matrix spec for /_matrix/client/r0/keys/query:
device_keys : {string: [string]} | Required. The keys to be downloaded. A map from user ID, to a list of device IDs, or to an empty list to indicate all devices for the corresponding user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions