Tuesday, April 17, 2018

Migrating or mixing casing

I'm working on a server that has two types of casing in the json encoded data.

First I have data stored in PascalCasing that is consumed server side which match fine with c#.

Second I have .NET Core MVC API:s which now automatically return camelCase.

Now I'm working on the client side which mostly consume the camelCase API:s but whenever it needs to access the stored data suddenly it has PascalCase.

Right now i have tools that convert the server side classes into strong typed interfaces for the client side. The problem is that right now this conversion translates all PascalCase into camelCase which is correct for the MVC API:s but incorrect for the stored data.

I have the feeling that i should stay with camelCase since that's the migration chosen for MVC.

I'm considering a few approaches.

Manually set the casing using [JsonProperty] on the classes representing the old stored data. And then set the default case resolver to use camelCase which applies to any new data structure.

Convert all old data structures into camelCase. Set the global case resolver. Thus no need for marking up every property.

Go all PascalCase on the api and thus be consistent between API and data structures.

Update the strong type converter to treat API and data structures differently. Keeping the PascalCase for data structures.

All these options are practically feasible. I'm not sure which approach makes the most sense.

I'm looking for any suggestions or experience with any of them. Are there any other unforseen consequences?

Migrating or mixing casing Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team