Legacy backend API endpoint returns JSON with units in an uncommon manner.
Instead of returning the measurement system “imperial” or “metric” it returns “kgs” or “lbs”.
Goal
Using JSON.net deserialize & serialize “kgs” to “metric” and “lbs” to “imperial” in our front-end app.
Solution
The solution is pretty simple. We have to define an enum, with “EnumMember” attributes on each element and use “StringEnumConverter” as preferred JsonConvertor. Here is the full and working example: