How do I pass my variable in JSON string as shown below?
string name = "john";
string json = @"{
'EmployeeName': name,
'EmployeeID': '123',
}
When I try the above I get an error.
Well you can concate the variable like
string json =@"{
'EmployeeName':" + name +",
'EmployeeID': '123',
}"
You can as well consider using string.Format() for this purpose and in C# 6 you can use variable interpolation syntax like
string json =$"{
'EmployeeName': {name} ,
'EmployeeID': '123',
}"