我正在尝试反序列化 json
{
"Type": "Correction",
"StartTime": "2007-12-19T03:00:00.0000000-08:00",
"EndTime": "2007-12-23T23:00:00.0000000-08:00",
"Parameters": [
{
"Key": "Something",
"Value": "1.8"
},
{
"Key": "Something2",
"Value": "0.10000000000000001"
},
{
"Key": "Something3",
"Value": "answer3"
},
],
}
Run Code Online (Sandbox Code Playgroud)
进入一个 Dto 包括public IReadOnlyDictionary<string, string> Parameters { get; set; }
许多其他的东西。
我正在使用最新的 newtonsoft 解串器,其功能是
var responseObject = JsonConvert.DeserializeObject<TResponse>(jsonResponse);
Run Code Online (Sandbox Code Playgroud)
但它返回错误
Newtonsoft.Json.JsonSerializationException : Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.IReadOnlyDictionary`2[System.String,System.String]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Run Code Online (Sandbox Code Playgroud)
是否有任何工具可以帮助我将 Json 响应更改为不同的响应,例如
"Parameters": …Run Code Online (Sandbox Code Playgroud)