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