Created
April 17, 2015 12:07
-
-
Save DanielFabian/93bbec50678f5e26f4b0 to your computer and use it in GitHub Desktop.
A playground for JSON.Net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Newtonsoft.Json | |
type FightSummary = | |
{ | |
event: string | |
winner: string option | |
loser: string option | |
} | |
type FighterOverallStatsInASpecificFight = | |
{ | |
fighter: string | |
opponent: string | |
[<JsonPropertyAttribute(PropertyName = "kd")>] knockdowns: int option | |
[<JsonPropertyAttribute(PropertyName = "sigStrPercent")>] sigStrikePercentage: int option | |
[<JsonPropertyAttribute(PropertyName = "tdPercent")>] takedownPercentage: int option | |
} | |
type FightInfo = | |
{ | |
fightSummary: FightSummary | |
fighter1Stats: FighterOverallStatsInASpecificFight | |
fighter2Stats: FighterOverallStatsInASpecificFight | |
} | |
let myFight = | |
{ fightSummary = | |
{ event = "MyEvent" | |
winner = None | |
loser = None } | |
fighter1Stats = | |
{ fighter = "Hulk" | |
opponent = "Hogan" | |
knockdowns = None | |
sigStrikePercentage = None | |
takedownPercentage = None } | |
fighter2Stats = | |
{ fighter = "Hogan" | |
opponent = "Hulk" | |
knockdowns = None | |
sigStrikePercentage = None | |
takedownPercentage = None } } | |
myFight | |
|> fun o -> printfn "%A" o; o | |
|> JsonConvert.SerializeObject | |
|> fun s -> printfn "%s" s; s | |
|> fun s -> JsonConvert.DeserializeObject<FightInfo>(s) | |
|> fun o -> printfn "%A" o; o | |
|> fun o -> printfn "%A" (o = myFight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment