Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert BSON to JSON #8

Open
seanhess opened this issue Nov 3, 2011 · 9 comments
Open

Convert BSON to JSON #8

seanhess opened this issue Nov 3, 2011 · 9 comments
Assignees

Comments

@seanhess
Copy link

seanhess commented Nov 3, 2011

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!

@TonyGen
Copy link
Owner

TonyGen commented Nov 10, 2011

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.

@gregwebs
Copy link

gregwebs commented Dec 9, 2011

you could see what happens if you use deriving Generic

https://github.com/bos/aeson/blob/master/examples/Generic.hs

@seanhess
Copy link
Author

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:
#8 (comment)

@TonyGen
Copy link
Owner

TonyGen commented Dec 20, 2011

Hi Sean, so how did you convert BSON to JSON using Generics?

@seanhess
Copy link
Author

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 [email protected] wrote:

Hi Sean, so how did you convert BSON to JSON using Generics?


Reply to this email directly or view it on GitHub:
#8 (comment)

@tobyhede
Copy link

+1 to that. Attempting to get generics working at the moment

@ghost ghost assigned TonyGen Dec 27, 2011
@seanhess
Copy link
Author

seanhess commented Jan 3, 2012

Did anybody get this working? Example?

@gregwebs
Copy link

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

@jhickner
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants