Insert from JSON file using C Driver.

Showing 1-3 of 3 messages
Insert from JSON file using C Driver. Antoine 12/26/11 9:11 AM
Hi List,

I'm new to MongoDB and still evaluating it. I am writing an
application that uses JSON to store data into text files. I would like
to have this application working with mongoDB. Is they a way to import
the JSON String into a MongoDB collection using the C driver ?. As far
I have seen, I could only insert BSON objects, but no way to fill a
BSON object from JSON String.

Any tricks for that ?

Thanks for help!

/Antoine
Re: Insert from JSON file using C Driver. Nat 12/26/11 6:40 PM
MongoDB C driver doesn't parse JSON. You have to use JSON parser to read JSON string and parse them into BSON representation manually.
Re: [mongodb-user] Insert from JSON file using C Driver. Gergely Nagy 12/27/11 2:33 AM
> I'm new to MongoDB and still evaluating it. I am writing an
> application that uses JSON to store data into text files. I would like
> to have this application working with mongoDB. Is they a way to import
> the JSON String into a MongoDB collection using the C driver ?. As far
> I have seen, I could only insert BSON objects, but no way to fill a
> BSON object from JSON String.

It is certainly possible with the official C driver too, as Nat wrote,
but this question was asked before, a couple of months ago. At that
point, I threw together a short tutorial using my libmongo-client C
library and json-c.

The tutorial is available at
http://algernon.github.com/libmongo-client/tut_json2bson.html (source
at https://github.com/algernon/libmongo-client/blob/master/docs/tutorial/examples/tut_json2bson.c)

Hope that helps.

--
|8]