【发布时间】:2019-07-28 23:10:26
【问题描述】:
我正在尝试在我的代码 (C#) 中创建以下 JSON 结果,因为这是我使用的 API 希望 JSON 的样子,但无法准确创建它,因此这就是 API 返回的原因有错误。
最终结果:
{
"reportKey" : {
"key" : "552d20ce-1269-4cb4-a679-0cd51d3e2058"
}
}
在我的代码中,我有
var reportKey = new KeyValuePair<string, string>("key", reportId);
var requestJson = new { reportKey };
当我通过使用JsonConvert 序列化这个requestJson 来查找JSON 值时,它会出现
{ reportKey : { key : "key", value : "CBHJ1234" } }
不是我想要的方式。
关于我可能做错的任何想法?我可能不想在这里使用KeyValuePair,对吧?
【问题讨论】:
-
用字典怎么样