Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB+Java - parsing JSON via com.mongodb.util.JSON.parse

Tags:

java

json

mongodb

I am using com.mongodb.util.JSON.parse to parse a JSON file to DBObject. How do I specify dates, refs, and objects IDs in the JSON file?

like image 594
jeffreyveon Avatar asked Oct 11 '11 10:10

jeffreyveon


1 Answers

Dates : { myDate: {$date: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" } } // Date in the mentioned ISODate string format.

Refs : { myRef : { $ref : <collname>, $id : <idvalue>[, $db : <dbname>] } } // collname is collection name, idvalue is the _id of the referred document and optionally dbname is the database the document is in.

ObjectIds : { _id : {$oid: "4e942f36de3eda51d5a7436c"} }

like image 71
Remon van Vliet Avatar answered Oct 21 '22 00:10

Remon van Vliet