how to parse JSON thanks
To parse JSON, you use Uno.Data.Json
. It is unfortunately not very well documented yet, but here’s a small example:
public static List<Song> Deserialize(string data)
{
var json = JsonReader.Parse(data);
var songs = new List<Song>();
for (int i=0; i<json["songs"].Count; i++)
{
var s = json["songs"][i];
songs.Add(new Song(s["id"].AsInteger(), s["votes"].AsInteger(), s["artist"].AsString(), s["title"].AsString()));
}
return songs;
}
Here’s some example JSON that is parsed by that function:
{
"songs": [
{"id":"1", "votes":"3", "artist":"120 Days", "title":"Lucid Dreams"},
{"id":"2", "votes":"2", "artist":"A-ha", "title":"The Sun Always Shines On TV"},
{"id":"3", "votes":"1", "artist":"A-Trak", "title":"Say Whoa"}
]
}