My current asp net core project is supporting only camel case. We are adding another external api so client can call it. However, the client has been setup to send it properties as snake case. That results in null value inside our api process. Is there a way to setup our project so that it would support both scenarios camel case and snake case as well ? Thank you
Asked
Active
Viewed 417 times
1
-
By *support both scenarios camel case and snake case* do you mean that JSON properties named `fooCase` and `foo_case` would both get bound automatically to the c# property `FooCase`? Or that one specific endpoint would use snake case while all the rest use camel case? – dbc Oct 14 '22 at 00:27
-
1If you just need snake_case model binding for one or two input models, couldn't you just add `[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]` to those models as shown in [this answer](https://stackoverflow.com/a/54540599/3744182) by Brian Rogers to [Automatically bind pascal case c# model from snake case JSON in WebApi](https://stackoverflow.com/q/54528475/3744182)? – dbc Oct 14 '22 at 00:38
-
Thanks @dbc. It works :) Yo mind posting it as an answer, and I will mark it for you – Hoang Minh Oct 14 '22 at 03:23