Skip to content

Add support to serializeNulls in the DefaultSerializer/GSONFactory #256

@ddellsperger

Description

@ddellsperger

We're currently in the progress of migrating from the 2.x graph-sdk-java to the 4.x branch of the graph-sdk-java, but the changes that we're seeing mostly are impacted by the serializer in the graph-sdk-java-core here. We previously used the raw JSON object data that was stored in the IJsonBackedObject implementation classes to get the exact response from the rest call. This provided us with a one-to-one representation of the API calls that the graph API returns. With the 3.x line on, this behavior changes as we migrate to the DefaultSerializer as the DefaultSerializer changes the representation of nulls (that are attributes of the Java object, but not that are in the additionalDataManager) to no longer serialize to a string. Since the change in 2.x to 3.x+ of the msgraph-sdk-java we're going to lose some of our support downstream in our other services that may not be java due to this change in structure. There have also been some changes to not really enable the leveraging of things like the GSONFactory which makes extending the ISerializable interface difficult. I'm wondering if it's possible to add an option to the DefaultSerializer to enable the gson option to serlialize nulls. I'm happy to submit a PR, but want to make sure I'm not potentially causing a disruption in a class that may not be accepted due to the desired behavior within the core sdk.

Expected behavior

Serialization of api responses via the SDK to at least provide the fields that the api provides in response.

Actual behavior

Serialization of the JSON objects throws away most of the null values

Steps to reproduce the behavior

Compare a response for something like the sendMessage Teams API serialized via the DefaultSerializer to the examples in the API documentation.
AB#10484

Metadata

Metadata

Assignees

Labels

Standard GitHub labelIssue caused by core project dependency modules or libraryenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions