-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
It seems version 1.4 introduced a breaking change. This can be reproduced with the script below. With v1.3.13 it is able to deserialise the file, but with v1.4.34 it fails.
Is there a fix to make this work with v1.4?
Game.json
{
"lane": 1,
"playedGame": {
"holes": 0,
"frames": [
[
"Strike",
19
],
[
{
"Case": "Miss",
"Fields": [
"Seven",
"Two"
]
},
28
],
[
{
"Case": "Spare",
"Fields": [
"Nine"
]
},
48
],
[
"Strike",
68
],
[
{
"Case": "Spare",
"Fields": [
"Nine"
]
},
87
],
[
{
"Case": "Spare",
"Fields": [
"Nine"
]
},
106
],
[
{
"Case": "Spare",
"Fields": [
"Nine"
]
},
122
],
[
{
"Case": "Spare",
"Fields": [
"Six"
]
},
139
],
[
{
"Case": "Miss",
"Fields": [
"Seven",
"One"
]
},
147
],
[
{
"Case": "Miss",
"Fields": [
"Seven",
"One"
]
},
155
]
],
"spares": 5,
"strikes": 2,
"totalScore": 155,
"finishedDate": "2025-03-26T06:00:25",
"singleSpares": 4,
"spareAttempts": 8,
"strikesOnStrike": 0,
"singleSpareAttempts": 4,
"strikesOnStrikeAttempts": 2
},
"playerName": "Stoffe",
"imagePartName": "/01/2025-03-26_060025.jpg"
}
Game.fsx
#r "nuget: FSharp.SystemTextJson, 1.3.13" // works
//#r "nuget: FSharp.SystemTextJson, 1.4.34" // fails
open System
open System.IO
type FrameRollType =
| Empty
| Strike
| Spare
| Nine
| Eight
| EightHole
| Seven
| SevenHole
| Six
| SixHole
| Five
| FiveHole
| Four
| FourHole
| Three
| Two
| One
| Miss
| Skip
| Restart
| Unknown
type LastFrameType =
| DoubleStrike of FrameRollType
| StrikeSpare of FrameRollType
| StrikeMiss of FrameRollType * FrameRollType
| SpareExtra of FrameRollType * FrameRollType
| Miss of FrameRollType * FrameRollType
type FrameRoll =
| Strike
| Spare of FrameRollType
| Miss of FrameRollType * FrameRollType
| LastFrame of LastFrameType
type Frame = FrameRoll * int
type PlayedGame = {
Frames: Frame list
TotalScore: int
Strikes: int
StrikesOnStrike: int
StrikesOnStrikeAttempts: int
Spares: int
SpareAttempts: int
Holes: int
SingleSpares: int
SingleSpareAttempts: int
FinishedDate: DateTime
}
type PlayerGame =
{ PlayerName: string
Lane: int
PlayedGame: PlayedGame }
module Json =
open System.Text.Json
open System.Text.Json.Serialization
let opts = JsonSerializerOptions(
WriteIndented = true,
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase)
JsonFSharpOptions()
.WithUnionUnwrapFieldlessTags()
.AddToJsonSerializerOptions(opts)
let fromJson<'a> (s: string) = JsonSerializer.Deserialize<'a>(s, opts)
Json.fromJson<PlayerGame>(File.ReadAllText "Game.json")
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working