[英]c# inserting variable in JSON string by escaping quotes
我有這個 JSON 雙引號字符串,我想在里面插入變量 idValue
string json = @"
{
""Request"":
{
""ElementList"":
{
""id"": ""idValue""
}
}
}
在常規字符串中,這可以通過 "+idValue+" 完成,但是當我有這些雙引號時,我怎么能在這里做到呢? 謝謝。
你可以這樣做 :
string json = @"
{
""Request"":
{
""ElementList"":
{
""id"": """+ idValue + @"""
}
}
}";
但我個人更喜歡使用 Json 庫來字符串化我的東西。
編輯:在字符串中添加了缺失的引號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.