dvsekhvalnov / jose-jwt

Ultimate Javascript Object Signing and Encryption (JOSE), JSON Web Token (JWT) and Json Web Keys (JWK) Implementation for .NET and .NET Core
MIT License
921 stars 183 forks source link

JSON casing breaking change 4.0 #217

Open DanFTRX opened 1 year ago

DanFTRX commented 1 year ago

https://github.com/dvsekhvalnov/jose-jwt/commit/13f25f9cd67324a134e1b87b31c305b30729591c added camel case overrides on all json serialization in the library. This is a change from before when it would preserve the casing provided. It's also not easily worked around as the JsonSerializerOptions are private in the JsonMapper class.

dvsekhvalnov commented 1 year ago

Hey @DanFTRX ,

i guess it was intentional, can't recall why exactly today, but probably there were a reasons.

I'm curious to see unit tests that were working on v4.0 but broken now on 4.1?

DanFTRX commented 1 year ago

My problem is that I have a different language client with a case sensitive JSON parser (I could write you a unit test showing you that a case sensitive parser won't work with the new casing, but I'm not sure that will be useful). One could argue that case sensitivity on the client was a mistake, but I can't change the past and in the end a change to the library has broken my workflow.

I understand the new default may be intentional, but can you provide the ability to modify the settings on the JsonMapper class (or a constructor that takes in a SerializationSettings and DeserializationSettings rather than the defaults) to allow easy modification of this new behavior without having to recreate the entire class?

Also this change in behavior should be documented in the release notes for the release it occurred in. (I think it was the 4.0 release?)

dvsekhvalnov commented 1 year ago

Yeah, can do it, seems to be same request as https://github.com/dvsekhvalnov/jose-jwt/issues/214

One thing is, i'm not sure what will break if you change default casing. May be more viable option for you will be to use methods that returning bare string and handle json serialization yourself behind library?