I try to convert a C# class
to a JSON object
.
I have tried it using the JsonConvert.SerializeObject
function. But I always end up with \\
in the result.
string data = JsonConvert.SerializeObject(rootObject);
public class JiraApiObject
{
public RootObject rootObject { get; set; }
public class Project {
public string key { get; set; }
}
public class Issuetype {
public string name { get; set; }
}
public class Fields {
public Project project { get; set; }
public string summary { get; set; }
public Issuetype issuetype { get; set; }
}
public class RootObject {
public Fields fields { get; set; }
}
}
This is the result returned when I serialize the RootObject of the JiraApiObject. Full of reverse slashes.
"{\
"fields\":{
\"project\":
{
\"key\":\"FOO\"
},
\"summary\":\"Test the REST API\",
\"issuetype\": {
\"name\":\"Task\"
}
}
}"
{
"fields": {
"project":
{
"key": "FOO"
},
"summary": "Test the REST API",
"issuetype": {
"name": "Task"
}
}
}
What is the best way to get rid of these \\
in the actual result?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.