-
Notifications
You must be signed in to change notification settings - Fork 184
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
Allow easy subclassing default IJsonMapper implementations: to let adjust settings easily. #214
Comments
Hi @RufusJWB , can you please share code that producing it? And also environment details, .net version, core or framework, OS, json serializer (newtonsoft vs. system.text.json), e.t.c. I haven't seen it in my setup, may be env specific issue or json serializer specific. |
Hi @dvsekhvalnov ! Thank you for your support! Please find following the sources, that generate this output:
I'm using Visual Studio Professional 2022, Version 17.5.0 Preview 2.0. The application is a console application targeting .net 7. |
@RufusJWB , try: {"JWK", jwk.ToDictionary() } // instead of just 'jwk' |
I can confirm, that this works. But it seems to be a rather ugly work-around. I would like to propose, to expose the serializer options of the serializer, as there is no global way of setting them: dotnet/runtime#31094 (comment) |
Your question - is exactly why library is trying to avoid serialization/deserialization of objects at all :) Because there is no guarantee that you will use System.Text.Json. It can be Newtonsoft or something else, and then suddenly library have to deal with all those options: skip nulls, avoid defaults, e.t.c. multiplied by number of json parser implementation. Trying to stick to bare minimum which more or less working same across everything: primites, maps and lists :) |
I totally understand that, but it would help a lot, if you would make the Serializer / Deserializer property publicly available: https://github.com/dvsekhvalnov/jose-jwt/blob/master/jose-jwt/json/JsonMapper.cs#L13 |
But you can always register your own JsonMapper with any settings you like: https://github.com/dvsekhvalnov/jose-jwt#settings isn't it what you looking for if you want to adjust default behavior? i can make SerializeOptions/DeserializeOptions |
That's something I'd appreciate as I want to avoid implementing my own JsonMapper just for changing some basic setting. You know, programmers are lazy people :-) |
Okay, should be easy. How badly you want it @RufusJWB ? Like right now or can wait? |
It can wait. It's just about code aesthetics. The proposed work around works fine. |
Okay, you can also just submit PR for this any time, can speed up things :) |
Is it possible to tell the default JSON serializer to ignore empty fields of a JWK and don't serialize them?
Currently my JWS header looks like this after serialization:
And I'd like to have it look like this:
The text was updated successfully, but these errors were encountered: