I have the data below and I'm trying to read the data and allocate each in variables but can not get the data in the info, still giving me null or blank for email and phone
{
"_id": ObjectId ( "56c570d904df6c51b463da54"),
"Name": "John Smith"
"Age": 31,
"Info": {
"Email", "[email protected]"
"Phone", "+987654321"
}
}
below the java code
findAll.forEach (new Block <Document> () {
@Override
public void apply (Document document) {
String name = document.getString ( "name")!= null? document.getString ( "name"): "";
int age = document.getInteger ( "age")!= null? document.getInteger ( "age"): 0;
String email = document.getString ( "info.email")!= null? document.getString ( "info.email") "";
String phone = document.getString ( "info.phone")! = null? document.getString ( "info.phone") "";
Costumer costumer = new Costumer (name, age, email, phone);
System.out.println (costumer);
}
});