Data.Text JSON instance

1
2
3
4
5
6
7
import  Text.JSON
import  Text.JSON.Generic (toJSON, fromJSON)
import  Data.Text (Text, pack, unpack)

instance JSON Text where
    showJSON = JSString . toJSString . unpack
    readJSON (JSString s) = return (pack $ fromJSString s)