I have a class like below:
public class PCBulkRequest
{
public List<PCRequest> pcRequest { get; set; }
}
When I'm trying to convert this class to a JSON string I'm getting JSON with the property name included, which I don't want.
string json = JsonConvert.SerializeObject(pcRequest, Formatting.Indented);
Result :
{
"pcRequest": [
{
"name": "John",
"surname": "Elton"
},
{
"name": "John",
"surname": "Elton"
}
]
}
Expected result:
[
{
"name": "John",
"surname": "Elton"
},
{
"name": "John",
"surname": "Elton"
}
]
pcRequestas simple collection object to theSerializeObject. Like converting it fromList<PCBulkRequest>toList<string>.