Skip to content

Instantly share code, notes, and snippets.

@taion809
Created March 3, 2019 21:22
Show Gist options
  • Save taion809/099f3c67ba5c2e70197d134fe0976520 to your computer and use it in GitHub Desktop.
Save taion809/099f3c67ba5c2e70197d134fe0976520 to your computer and use it in GitHub Desktop.
F# json.net deserialize
namespace PoeIngester
open HttpFs.Client
open System.Net.Http
open Hopac
open Newtonsoft.Json
module Bookmark =
type responseBody = {
[<JsonProperty(PropertyName="next_change_id")>]
NextChangeId: string;
}
let apiUrl = "https://poe.ninja/api/Data/GetStats"
let fetch (client: HttpClient) = job {
let request = Request.createWithClient client Get (System.Uri(apiUrl))
use! response = getResponse request
let! body = Response.readBodyAsString response
let rb = JsonConvert.DeserializeObject<responseBody>(body)
return rb.NextChangeId
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment