In my Xamarin.Forms
app I use a socket.IO
library that fetches data from a Node.js server but I don't know about extracting the data from my result. The example method looks like this:
socket.On("event", (data) =>
{
Console.WriteLine(data);
});
When the result is a simple string, I can directly use it as in the console function above. But how do I extract the data when the result is a unknown datatype that contains multiple information, like this?
let send = {'firstString': string1, 'secondString': string2}
I guess a way could be to make the result a JSON object and read it out by it's keys but I don't know if that's a good way and how this would be done.
use Json.Net to parse the json
JObject obj = JObject.Parse(data);
var first = obj["firstString"].Value;
var second = obj["secondString"].Value;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.