Skip to content

Instantly share code, notes, and snippets.

@jovaneyck
Created June 18, 2017 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jovaneyck/40ed150675e112fd175012a4b13f8576 to your computer and use it in GitHub Desktop.
Save jovaneyck/40ed150675e112fd175012a4b13f8576 to your computer and use it in GitHub Desktop.
Generate types from sample JSON.
#r @"..\packages\Fsharp.Data\lib\net40\Fsharp.Data.dll"
open FSharp.Data
[<Literal>]
let sample = @"{
""title"" : ""Management 4.2"",
""author"" : {
""firstName"" : ""Jurgen"",
""lastName"" : ""Appelo""
},
""ISBN"" : ""978-0321123479"",
""createdAt"" : ""2017-04-07T23:03:52.692+02:00"",
""updatedAt"" : ""2017-06-09T13:44:31.728+02:00""
}"
type BookTypes = JsonProvider<sample, RootName="book">
let book = BookTypes.Book("title",BookTypes.Author("first name", "last name"),"isbn", System.DateTime.Now, System.DateTime.Now)
printfn "%A" book
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment