My mongo collections contains following documents
{
"syslog": [
{
"alertId": "N/A",
"time": "06:46:57",
"device": "10.10.20.1"
},
{
"alertId": "N/A",
"time": "06:47:30",
"device": "10.10.20.2"
}
]
}
now I want to read only values of given device.
Suppose if I set device="10.10.20.2" it will shows only "alertId": "N/A",
"time": "06:47:30",
"device": "10.10.20.2" for this I write java code as below
BasicDBObject criteria = new BasicDBObject();
criteria.put("syslog.device","10.10.20.2");
DBCursor cur = coll.find(criteria);
while(cur.hasNext() && !isStopped()) {
String json = cur.next().toString();
}//end of while
When I print json it shows me whole json values. How I should find only selected values of given device?
When I print json it shows me whole json values?