module TD.Data.TestVectorStringObject
(TestVectorStringObject(..)) 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.TestString as TestString
data TestVectorStringObject
= TestVectorStringObject
{ TestVectorStringObject -> Maybe [TestString]
value :: Maybe [TestString.TestString]
}
deriving (TestVectorStringObject -> TestVectorStringObject -> Bool
(TestVectorStringObject -> TestVectorStringObject -> Bool)
-> (TestVectorStringObject -> TestVectorStringObject -> Bool)
-> Eq TestVectorStringObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestVectorStringObject -> TestVectorStringObject -> Bool
== :: TestVectorStringObject -> TestVectorStringObject -> Bool
$c/= :: TestVectorStringObject -> TestVectorStringObject -> Bool
/= :: TestVectorStringObject -> TestVectorStringObject -> Bool
Eq, Int -> TestVectorStringObject -> ShowS
[TestVectorStringObject] -> ShowS
TestVectorStringObject -> String
(Int -> TestVectorStringObject -> ShowS)
-> (TestVectorStringObject -> String)
-> ([TestVectorStringObject] -> ShowS)
-> Show TestVectorStringObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestVectorStringObject -> ShowS
showsPrec :: Int -> TestVectorStringObject -> ShowS
$cshow :: TestVectorStringObject -> String
show :: TestVectorStringObject -> String
$cshowList :: [TestVectorStringObject] -> ShowS
showList :: [TestVectorStringObject] -> ShowS
Show)
instance I.ShortShow TestVectorStringObject where
shortShow :: TestVectorStringObject -> String
shortShow TestVectorStringObject
{ value :: TestVectorStringObject -> Maybe [TestString]
value = Maybe [TestString]
value_
}
= String
"TestVectorStringObject"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"value" String -> Maybe [TestString] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [TestString]
value_
]
instance AT.FromJSON TestVectorStringObject where
parseJSON :: Value -> Parser TestVectorStringObject
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
"testVectorStringObject" -> Value -> Parser TestVectorStringObject
parseTestVectorStringObject Value
v
String
_ -> Parser TestVectorStringObject
forall a. Monoid a => a
mempty
where
parseTestVectorStringObject :: A.Value -> AT.Parser TestVectorStringObject
parseTestVectorStringObject :: Value -> Parser TestVectorStringObject
parseTestVectorStringObject = String
-> (Object -> Parser TestVectorStringObject)
-> Value
-> Parser TestVectorStringObject
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TestVectorStringObject" ((Object -> Parser TestVectorStringObject)
-> Value -> Parser TestVectorStringObject)
-> (Object -> Parser TestVectorStringObject)
-> Value
-> Parser TestVectorStringObject
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [TestString]
value_ <- Object
o Object -> Key -> Parser (Maybe [TestString])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"value"
TestVectorStringObject -> Parser TestVectorStringObject
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TestVectorStringObject -> Parser TestVectorStringObject)
-> TestVectorStringObject -> Parser TestVectorStringObject
forall a b. (a -> b) -> a -> b
$ TestVectorStringObject
{ value :: Maybe [TestString]
value = Maybe [TestString]
value_
}
parseJSON Value
_ = Parser TestVectorStringObject
forall a. Monoid a => a
mempty