public static void main (String args[])
{
GetMorphiaDB morphia;
//String id = request.getParameter("id");
try {
morphia = GetMorphiaDB.getInstance();
Map<String,Object> output = new LinkedHashMap<String, Object>();
DB db = morphia.getDb();
DBCollection collection = db.getCollection("Transactions");
BasicDBObject allQuery = new BasicDBObject();
BasicDBObject fields = new BasicDBObject();
fields.put("referenceID", 1);
/*DBCursor cursor2 = collection.find(allQuery, fields);
while (cursor2.hasNext()) {
System.out.println(cursor2.next());
}*/
//System.out.println("\n2. Find where number = 5");
BasicDBObject whereQuery = new BasicDBObject();
whereQuery.put("referenceID", "E13F31BC80CE");
fields.put("referenceID", 1);
//fields.put("listEditions", 1);
fields.put("listEditions.listInsertion", 1);
fields.append("_id",false);
DBCursor curs = collection.find(whereQuery,fields);
while (curs.hasNext()) {
System.out.println(curs.next());
}
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (MongoException e) {
e.printStackTrace();
}
}
我有上面的程序,它给我的输出如下
{ "listEditions" : [ { "listInsertion" : [ { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0} , { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0}]} , { "listInsertion" : [ { "page" : 2 , "fromDate" : "14/06/2013" , "toDate" : "14/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0} , { "page" : 2 , "fromDate" : "14/06/2013" , "toDate" : "14/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0}]} , { "listInsertion" : [ { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0} , { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0}]} , { "listInsertion" : [ { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0} , { "page" : 2 , "fromDate" : "11/06/2013" , "toDate" : "11/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0}]} , { "listInsertion" : [ { "page" : 2 , "fromDate" : "15/06/2013" , "toDate" : "15/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0} , { "page" : 2 , "fromDate" : "15/06/2013" , "toDate" : "15/06/2013" , "size" : 240 , "color" : 0 , "colorType" : "All Colour" , "pagePosition" : 2 , "pagePositionType" : "Regular Page" , "sizeDimention" : "12x20" , "width" : 12.0 , "height" : 20.0}]}] , "referenceID" : "E13F31BC80CE"}
现在我想从innerDocument listInsertion 中获取值,它在[]
括号中的listEditions 内。
那么如何获得。