Public class WebSocketBase
{
Int code {get; set; }
Bool command {get; set; }
T the content {get; set; }
}
Is mainly used to accept the WebSocket sent information,
But different code code, will have different content, how do I determine the value of code, first
Then use the corresponding deserialization class go? Thank you for your attention:)
Using JsonConvert DeserializeObject,
CodePudding user response:
In terms of words, since the communication is using json into dynamic type dynamicAs follows:
Var Object=JsonConvert. DeserializeObject(json);
Var code=Object (" code ");
So can access code is the corresponding value through the code to match the T type