I have following classes,
public class Actions
{
public string say { get; set; }
public bool? listen { get; set; }
}
public class ActionsWrapper
{
public List<Actions> actions { get; set; }
public ActionsWrapper(string say, bool listen = false)
{
this.actions = new List<Actions>();
var action = new Actions();
action.say = say;
action.listen = listen;
this.actions.Add(action);
}
}
And I am using the following to generate Json
var actions = new ActionsWrapper(say: "Hi, how can I help you today?");
return JsonConvert.SerializeObject(actions);
This returns me following Json,
{"actions":[
{
"say":"Hi, how can I help you today?",
"listen": false
}
]}
Which is good, but I am sending this to Twilio API which has the requirement of the following format,
{
"actions": [
{
"say": "Hi, how can I help you today?"
},
{
"listen": false
}
]
}
So my question is, what changes do I need in my classes / NewtonSoft to get each property [say&listen] in separate curly braces?
[ ]indicates an array of objects...