Open seanhess opened 12 years ago
Hi Sean, thanks for the code. I will look at it in a few weeks. You could create your own package for this if you wanted. A third package on top of json and bson packages is ok.
you could see what happens if you use deriving Generic
https://github.com/bos/aeson/blob/master/examples/Generic.hs
That is awesome. That's pretty much exactly what I should have done. Thanks On Dec 9, 2011, at 2:13 PM, Greg Weber wrote:
you could see what happens if you use deriving Generic
https://github.com/bos/aeson/blob/master/examples/Generic.hs
Reply to this email directly or view it on GitHub: https://github.com/TonyGen/mongoDB-haskell/issues/8#issuecomment-3086010
Hi Sean, so how did you convert BSON to JSON using Generics?
I didn't. I just assumed that the above example did it. Does it not work?
On Dec 20, 2011, at 4:07 PM, Tony Hannanreply@reply.github.com wrote:
Hi Sean, so how did you convert BSON to JSON using Generics?
Reply to this email directly or view it on GitHub: https://github.com/TonyGen/mongoDB-haskell/issues/8#issuecomment-3226964
+1 to that. Attempting to get generics working at the moment
Did anybody get this working? Example?
Someone has done this with persitent-mongoDB. They have an Aeson -> PersistentValue converter. A PersistValue gets converted into BSON in persitent-mongoDB https://github.com/periodic/LoLLogs/blob/master/parser/Data/GameLog/PersistTH.hs
I've gotten good results by writing a conversion from Data.Bson.Value
to Aeson.Value
. Once you have an Aeson.Value
converting to JSON is as easy as running Aeson.encode
.
Code here: https://gist.github.com/4092219
Hi, I'm new to haskell, so I have no idea whether this kind of code belongs in the BSON repo, the JSON repo, or something else, but I needed a way to serialize BSON to JSON.
https://gist.github.com/1335856
Can you use this? (Note that it's not quite done). If not, where does this kind of mapping between two separate libraries live in haskell-land? BSON and JSON are such close cousins that it seems like it should be easier.
Is there a better way to do this?
Also note that it seems that most of the libraries use Text.Text now instead of CompactString, which made it annoying to convert between the two.
Thanks!