在将其标记为重复项之前,具有相似名称的其他问题与正则表达式相关,并且与我的问题不同。字符在传递到字典时没有正确转义
我有串
Principal = "{\"id\":\"number\"}"
如果我没有记错这应该逃避{"id":"number"}
。
然而,当我将它传递给下面的方法
Dictionary<string, object> folder = new Dictionary<string, object>();
folder.Add("Principal", Principal);
string json = JsonConvert.SerializeObject(folder);
Console.WriteLine(json);
它返回的
{
"Principal":"{\"id\":\"number\"}"
}
理想我想它返回
{
"Principal":{"id":"number"}
}
为什么持有引号和转义字符?我在这里做错了什么?
非常好,谢谢!我的代码仍然无法工作,但这部分是感谢你! – Mitch