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