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

ObjectMapper configuration for json serialization #28

Open
laurent-treeb opened this issue Apr 8, 2022 · 0 comments
Open

ObjectMapper configuration for json serialization #28

laurent-treeb opened this issue Apr 8, 2022 · 0 comments

Comments

@laurent-treeb
Copy link

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.

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

1 participant