'accessing object json.`params` (reserved keyword) from (dynamic)json in c#
I am calling an api which returns some json. The format of the received json is as follows:
{
"method": "depth.update",
"params": [
true,
{
"asks": [
[
"8000.00",
"9.6250"
]
],
"bids": [
[
"8000.00",
"9.6250"
]
]
},
"EOS_USDT"
],
"id": null
}
Note the Object paramswith asks and bids, which I am trying to access.
The json is beeing deserialized into a dynamic.
As shown in the example below, I can access the objects by calling json.method for instance.
// retrieve response
string message = Receivestring();
// deserialize
dynamic json = JsonConvert.DeserializeObject<dynamic>(message);
// check if we are in the correct method
if (json.method == "depth.update")
{
// -> this does not work <--
dynamic parameters = json.params;
}
else if (json.method == "other.method")
{
dynamic success = json.result;
}
issue:
json.params will not work. I guess it is a reserved keyword, Visual Studio tries to match.
How can I access json.params then?
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | D-Shih |
