haskell Data.Aeson.Value to Text

Viewed 2290
data User = User { city :: Text
                 , country :: Text
                 , phone :: Text
                 , email :: Text}

instance ToJSON User where
    toJSON (User a b c d)= object ["a" .= a
                                  ,"b" .= b
                                  ,"c" .= c
                                  ,"d" .= d]

test:: User -> IO Value
test u = do
    let j = toJSON u
    return j

What I want is Text like so

test::User -> IO Text
test u = do
    let j = pack ("{\"city\":\"test\",\"country\":\"test\",\"phone\":\"test\",\"email\":\"test\"}")
    return j

I can't figure it out how to go from Value to Text

2 Answers
Related