Skip to content

Instantly share code, notes, and snippets.

@csvan csvan/JSONClient

Last active Aug 29, 2015
What would you like to do?
Xamarin.Forms JSON client
namespace JSONClientExample
public class JSONClient
readonly string baseUrl;
readonly HttpClient client;
public JSONClient (string baseUrl)
this.baseUrl = baseUrl;
this.client = new HttpClient (new NativeMessageHandler ()) {
BaseAddress = new Uri (baseUrl),
public async Task<MyJSONObject> GetAsync (string url)
var response = await client.GetAsync (url);
response.EnsureSuccessStatusCode ();
var rawJSON = await response.Content.ReadAsStringAsync ();
var settings = new JsonSerializerSettings {
TypeNameHandling = TypeNameHandling.All
return JsonConvert.DeserializeObject <MyJSONObject> (rawJSON, settings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.