I am trying to create a JSON string content by passing a double typed value (named time). My JSON content is also containing a root header object (named UserAddTime). I would like to add time in Minutes object.
double time = 60;
var content = new StringContent
(@"{
'UserAddTime':
{
'Minutes':"+time+",
'TotalPrice':0.00,
'IsTaxIncluded':false
}
}",
Encoding.UTF8, "application/json");
It doesn't allow me to add time like this:
'Minutes':"+time+",
And shows me the red line error content LOC:
I am trying this solution, but not able to get my expected results like:
{
"UserAddTime" : {
"Minutes" : 60,
"TotalPrice" : 0.00,
"IsTaxIncluded" : false
}
}
Your any help will be really appreciated!

StringContentyou can narrow down to a JsonContent type, working directly with models and using factory methodJsonContent.Create.