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

Feature Request: Custom serializer option to handle Dynamic Template Data serialization #985

Open
shervinw opened this issue Mar 21, 2020 · 10 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@shervinw
Copy link

shervinw commented Mar 21, 2020

example:

var msg = new SendGridMessage();
var serializerSettings = new Newtonsoft.Json.JsonSerializerSettings
                {
                    NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                };
msg.SetTemplateData(dynamicTemplateData, serializerSettings);

Current options are far too restrictive, I can only see that decorating properties with JsonProperty has any type of effect.

Also, I'm sure this test is simply testing Newtonsofts lib.

@eshanholtz eshanholtz added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Mar 24, 2020
@eshanholtz
Copy link
Contributor

Pull requests to add this feature are welcome and will be reviewed based on priority, but Twilio SendGrid is not actively building new functionality for the library.

@shervinw
Copy link
Author

shervinw commented Mar 26, 2020

More than happy to do so! Following all guidelines!

Looking at open pull requests, may I ask the time it may take to merge this functionality?

@tunminster
Copy link

@shervinw @eshanholtz Not sure if the pull request is already there? we have bumped into this with .net 5. #1050

@childish-sambino
Copy link
Contributor

No PRs yet, but they are welcome!

@fabio-s-franco
Copy link

fabio-s-franco commented Aug 18, 2021

Over an year now and still no support to native .net serializer...

Aren't these client libraries supposed to supported by Twilio? There is even a PR just sitting there and really no real effort to make it happen. 3 days for now .net 2.1 end of support is there and this will not have happened.

@vdurante
Copy link

+1

@kshyju
Copy link

kshyju commented Jan 20, 2022

but Twilio SendGrid is not actively building new functionality for the library.

@eshanholtz Does this mean that there will not be a version of this library with System.Text.Json support? Currently some of the types has a strong dependency on JSON.NET.

Asking it here because1050 was closed as it was marked as dupe of this. Thanks!

@Sharparam
Copy link

Sharparam commented Feb 28, 2022

Would be good with some updates on this. We're hitting this as an issue as well when replacing Newtonsoft.Json with System.Text.Json.

Most other libraries have a way to set a custom serializer which lets us configure them properly, but this library does not.

Is development on this project stopped which means Twilio is no longer supplying an official C#/.NET SDK?

Edit: As an ugly workaround, since we only seem to have issues with TemplateData.

var templateDataJson = JsonSerializer.Serialize(templateData);
var njTemplateData = Newtonsoft.Json.JsonConvert.DeserializeObject<object?>(templateDataJson);
sendGridMessage.SetTemplateData(njTemplateData);

Basically, we take the current template data (deserialized with STJ, so it has JsonElement and friends), serialize it to plain JSON, then deserialize that using Newtonsoft.Json to get the proper dynamic JSON types (JToken and friends).

@fabio-s-franco
Copy link

Had to employ the same ugly and ineffective solution @Sharparam .

It's funny how they put it in the home page as they want this library to be community driven. But someone comes, makes all the effort (a lot of effort), keeps it updated, follow the guidelines and after almost an entire year and the pull request is still there:

#1110

Don't think there is enough respect to the effort being made there. And this will never be community driven when there is a gatekeeper acting as a bottleneck for community driven work.

@Jericho
Copy link

Jericho commented Apr 25, 2022

If anybody is still waiting for a solution to customize how you dynamic template data is serialized, I suggest you have a look at StrongGrid which is an alternative to SendGrid's client (disclaimer: I'm the author). StrongGrid allows you to specify your own serialization options, including the naming policy.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

9 participants