make database less brittle when something's wrong with the JSON file
This commit is contained in:
parent
2768934c7c
commit
3ee97406f1
|
@ -528,11 +528,11 @@ makeLenses ''GameStats
|
|||
|
||||
instance FromJSON Database where
|
||||
parseJSON = withObject "Database" $ \v -> Database
|
||||
<$> v .: "players"
|
||||
<*> v .: "goalies"
|
||||
<*> v .: "games"
|
||||
<*> v .: "home_game_stats"
|
||||
<*> v .: "away_game_stats"
|
||||
<$> v .:? "players" .!= []
|
||||
<*> v .:? "goalies" .!= []
|
||||
<*> v .:? "games" .!= 0
|
||||
<*> v .:? "home_game_stats" .!= newGameStats
|
||||
<*> v .:? "away_game_stats" .!= newGameStats
|
||||
|
||||
instance ToJSON Database where
|
||||
toJSON (Database players goalies games hgs ags) = object
|
||||
|
|
Loading…
Reference in New Issue
Block a user