jeffreyveon
jeffreyveon

Reputation: 13830

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

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?

Upvotes: 6

Views: 5082

Answers (1)

Remon van Vliet
Remon van Vliet

Reputation: 18595

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"} }

Upvotes: 8

Related Questions