I have the following BasicDBObject object:
{
"name":"joe"
"jobs":
[
{"adress" : "adress1"
"years": 2},
{"adress" : "adress2"
"years" :3}
}
I want to get the "jobs" field and enter the "adress" field and "years" field
I traying somethink like ....object.get("jobs") ....get "adress" and " years" fields.
please help
Use BasicDBList to read the array inside the "jobs". Then iterate over the array to get each object.
BasicDBList jobsArr = (BasicDBList) object.get("jobs");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.