module TD.Data.TestVectorIntObject
(TestVectorIntObject(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.TestInt as TestInt
data TestVectorIntObject
= TestVectorIntObject
{ TestVectorIntObject -> Maybe [TestInt]
value :: Maybe [TestInt.TestInt]
}
deriving (TestVectorIntObject -> TestVectorIntObject -> Bool
(TestVectorIntObject -> TestVectorIntObject -> Bool)
-> (TestVectorIntObject -> TestVectorIntObject -> Bool)
-> Eq TestVectorIntObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestVectorIntObject -> TestVectorIntObject -> Bool
== :: TestVectorIntObject -> TestVectorIntObject -> Bool
$c/= :: TestVectorIntObject -> TestVectorIntObject -> Bool
/= :: TestVectorIntObject -> TestVectorIntObject -> Bool
Eq, Int -> TestVectorIntObject -> ShowS
[TestVectorIntObject] -> ShowS
TestVectorIntObject -> String
(Int -> TestVectorIntObject -> ShowS)
-> (TestVectorIntObject -> String)
-> ([TestVectorIntObject] -> ShowS)
-> Show TestVectorIntObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestVectorIntObject -> ShowS
showsPrec :: Int -> TestVectorIntObject -> ShowS
$cshow :: TestVectorIntObject -> String
show :: TestVectorIntObject -> String
$cshowList :: [TestVectorIntObject] -> ShowS
showList :: [TestVectorIntObject] -> ShowS
Show)
instance I.ShortShow TestVectorIntObject where
shortShow :: TestVectorIntObject -> String
shortShow TestVectorIntObject
{ value :: TestVectorIntObject -> Maybe [TestInt]
value = Maybe [TestInt]
value_
}
= String
"TestVectorIntObject"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"value" String -> Maybe [TestInt] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [TestInt]
value_
]
instance AT.FromJSON TestVectorIntObject where
parseJSON :: Value -> Parser TestVectorIntObject
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"testVectorIntObject" -> Value -> Parser TestVectorIntObject
parseTestVectorIntObject Value
v
String
_ -> Parser TestVectorIntObject
forall a. Monoid a => a
mempty
where
parseTestVectorIntObject :: A.Value -> AT.Parser TestVectorIntObject
parseTestVectorIntObject :: Value -> Parser TestVectorIntObject
parseTestVectorIntObject = String
-> (Object -> Parser TestVectorIntObject)
-> Value
-> Parser TestVectorIntObject
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TestVectorIntObject" ((Object -> Parser TestVectorIntObject)
-> Value -> Parser TestVectorIntObject)
-> (Object -> Parser TestVectorIntObject)
-> Value
-> Parser TestVectorIntObject
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [TestInt]
value_ <- Object
o Object -> Key -> Parser (Maybe [TestInt])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"value"
TestVectorIntObject -> Parser TestVectorIntObject
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TestVectorIntObject -> Parser TestVectorIntObject)
-> TestVectorIntObject -> Parser TestVectorIntObject
forall a b. (a -> b) -> a -> b
$ TestVectorIntObject
{ value :: Maybe [TestInt]
value = Maybe [TestInt]
value_
}
parseJSON Value
_ = Parser TestVectorIntObject
forall a. Monoid a => a
mempty