module Text.JSON.Combinator.Examples where
import Text.JSON.Combinator
import qualified Text.JSON as J
import Text.JSONb
import Text.JSON.Parsec
import Control.Applicative
import qualified Data.ByteString as S
example1 ::
FilePath
-> IO ()
example1 p =
do r1 <- readJSONFile p :: IO (Either String JSON)
r2 <- readJSONFile p :: IO (Either ParseError J.JSValue)
let f r = withObjectFields (
withString r
. withNumber (+1)
. jnot
)
k1 = printJSON . f S.reverse <$> r1
k2 = printJSON . f reverse <$> r2
either print S.putStrLn k1
either print putStrLn k2