Deserializing Json data with Xamarin.Forms C# Deserializing Json data with Xamarin.Forms C# json json

Deserializing Json data with Xamarin.Forms C#


The first thing I would do is use this tool to convert your json to a class:http://json2csharp.com/

Once you've done this, you can use the Newtonsoft library that you are already using to convert the json in to a typed object from your class like this:

var object = JsonConvert.DeserializeObject<ClassName>(json);

Once you have done this, you can use the ImageUrl from the object to download the image.You can now use WebClient in Xamarin which is probably the best way to download an image. You can see a post about it here:

How to download image from url

I'm not sure what your GetGiphyImageUrl method does, but this is how you can load the data in to an Image control:

                using (var client = new WebClient())                {                    bytes = await client.DownloadDataTaskAsync(Url);                    Source = ImageSource.FromStream(() => new MemoryStream(bytes));                }