A simple Foreign/JSON library based on the Purescript's RowToList feature.
Requires compiler version 0.11.6 or greater.
See the API Docs or the tests for usage.
I use this in my simple-rpc-telegram-bot project to read configs quickly and easily:
newtype FilePath = FilePath String
derive instance ntFP :: Newtype FilePath _
derive newtype instance rfFP :: ReadForeign FilePath
newtype Token = Token String
derive instance ntT :: Newtype Token _
derive newtype instance rfT :: ReadForeign Token
newtype Id = Id Int
derive instance ntI :: Newtype Id _
derive newtype instance rfI :: ReadForeign Id
type Config =
{ token :: Token
, torscraperPath :: FilePath
, master :: Id
}
getConfig :: IO (F Config)
getConfig = liftAff $ readJSON <$> readTextFile UTF8 "./config.json"