We're trying to deserialize the following JSON string:
string responseData = "{\"status\":\"2000\",\"data\":[{\"response\":{\"TrxId\":4972783,\"result\":1,\"accruedPoints\":null}}],\"error\":null}";
var dic = JsonConvert.DeserializeObject<Dictionary<object, object>>(responseData);
object value, error, oData;
dic.TryGetValue("status", out value);
dic.TryGetValue("data", out oData);
string status = Convert.ToString(value);
string data = Convert.ToString(oData);
Dictionary<string, string> result = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
We're facing problems deserializing data
. Following is the exception:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.Object,System.Object]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Is there a better way to deserialize this JSON object?
We need the accruedPoints
value.