@@ -49,6 +49,7 @@ module Cardano.Benchmarking.Profile.Types (
4949--------------------------------------------------------------------------------
5050
5151import Prelude
52+ import Data.Maybe (isJust )
5253import GHC.Generics
5354-- Package: aeson.
5455import qualified Data.Aeson as Aeson
@@ -97,11 +98,15 @@ data Profile = Profile
9798
9899 -- TODO: Somehow merge these two!
99100 , preset :: Maybe String
100- , overlay :: Maybe Aeson. Object
101+ , overlay :: Aeson. Object -- TODO: Add `Maybe`, empty object for compatibility.
101102 }
102103 deriving (Eq , Show , Generic )
103104
104- instance Aeson. ToJSON Profile
105+ instance Aeson. ToJSON Profile where
106+ toJSON = Aeson. genericToJSON
107+ -- TODO: Remove after removing `jq` profiles.
108+ -- To compare JSONs without "desc", "chaindb" and "preset" properties.
109+ (Aeson. defaultOptions {Aeson. omitNothingFields = True })
105110
106111instance Aeson. FromJSON Profile where
107112 parseJSON = Aeson. genericParseJSON
@@ -202,7 +207,11 @@ data Composition = Composition
202207 }
203208 deriving (Eq , Show , Generic )
204209
205- instance Aeson. ToJSON Composition
210+ instance Aeson. ToJSON Composition where
211+ toJSON = Aeson. genericToJSON
212+ -- TODO: Remove after removing `jq` profiles.
213+ -- To compare JSONs without the "with_chaindb_server" property.
214+ (Aeson. defaultOptions {Aeson. omitNothingFields = True })
206215
207216instance Aeson. FromJSON Composition where
208217 parseJSON = Aeson. genericParseJSON
@@ -462,11 +471,13 @@ data Plutus = Plutus
462471
463472instance Aeson. ToJSON Plutus where
464473 toJSON p =
465- Aeson. object
474+ Aeson. object $
466475 [ " type" Aeson. .= plutusType p
467476 , " script" Aeson. .= plutusScript p
468- , " redeemer" Aeson. .= redeemer p
469477 ]
478+ ++
479+ -- TODO: Needed to replicate the old "jq" JSON output.
480+ [" redeemer" Aeson. .= redeemer p | isJust (redeemer p)]
470481
471482instance Aeson. FromJSON Plutus where
472483 parseJSON =
0 commit comments