I have two controller FooController
and BooController
(the last is for a backward compatibility), I want only the FooController
will return its model with upper camel case notation ("UpperCamelCase").
For example:
public class MyData
{
public string Key {get;set;}
public string Value {get;set;}
}
public class BooController : ControllerBase
{
public ActionResult<MyData> GetData() { ... }
}
public class FooController : ControllerBase
{
public ActionResult<MyData> GetData() { ... }
}
The desired GET
output:
GET {{domain}}/api/Boo/getData
[
{
"key": 1,
"value": "val"
}
]
GET {{domain}}/api/Foo/getData
[
{
"Key": 1,
"Value": "val"
}
]
If I'm using the AddJsonOptions
extension with option.JsonSerializerOptions.PropertyNamingPolicy = null
like:
services.AddMvc()
.AddJsonOptions(option =>
{
option.JsonSerializerOptions.PropertyNamingPolicy = null;
});
both BooController
and FooController
returns the data with upper camel case notation.
How to make only the FooController
to return the data in upper camel case notation format?