Created
November 2, 2011 23:14
-
-
Save seanhess/1335261 to your computer and use it in GitHub Desktop.
BSON to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-} | |
-- cabal install json | |
-- cabal install mongoDB | |
import Text.JSON | |
import Text.JSON.Generic | |
import Database.MongoDB | |
import Data.Bson | |
-- this doesn't help | |
instance JSON (Field) where | |
showJSON doc = JSNull | |
readJSON (JSObject obj) = Error "woot" | |
main = do | |
-- note that overloaded strings makes JSON not able to handle my literal strings for some reason | |
-- putStrLn $ encode $ toJSON "hello" | |
putStrLn $ encode $ toJSON ["hello" =: "world"] | |
{- | |
/Users/seanhess/sandbox/Haskell/web/bsonToJson.hs:22:25: | |
No instance for (Data Field) | |
arising from a use of `toJSON' | |
Possible fix: add an instance declaration for (Data Field) | |
In the second argument of `($)', namely | |
`toJSON ["hello" =: "world"]' | |
In the second argument of `($)', namely | |
`encode $ toJSON ["hello" =: "world"]' | |
In the expression: putStrLn $ encode $ toJSON ["hello" =: "world"] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment