Reputation: 1111
I have an appsettings.json file in my C# app. It contains field with names in upper case:
{
"FIELD_ONE": "foo",
"FIELD_TWO": "bar"
}
But I would like to bind it to class with camel-case naming style:
public class MySettings
{
public string FieldOne { get; set; }
public string FieldTwo { get; set; }
}
How can I bind this appsettings to MySettings
instance?
Upvotes: 0
Views: 149
Reputation: 86
This could be a solution:
public class MySettings
{
[JsonProperty("FIELD_ONE")]
public string FieldOne { get; set; }
[JsonProperty("FIELD_TWO")]
public string FieldTwo { get; set; }
}
Upvotes: 1