I am trying to create the JSON data using NewtonSoft in c#. I'm using following code-
[JsonProperty(PropertyName = "student")]
public List<Student> obj{ get; set; }
which will create the list of JSON object for students. I wondered, is there any option to give the PropertyName dynamically, like here I'm using PropertyName = "student", I want take name dynamically.
For Example I want following JSON Data-
{
"id": "123",
"st1": [
{
"Name": "chinna",
},
],
"st2": [
{
"Name": "krishan",
},
]
}
where st1 and st1 are PropertyName which I want to take dynamically.