I am facing an issue with accessing a nested json object in JavaScript. The main json object contains another json object called "from", which in turn has a json object named value, and inside value is the address property that I need to access. Here's the code snippet:
let data = doc.data();
const email = JSON.parse(data.Emails[z]);
let emailBody = email.body;
let emailSubject = email.subject;
let oldDate = email.date;
let emailFrom = email.from.value.address;
I expected email.from.value.address
to work but it's not fetching the address as desired.
While email.from
allows me to access the from object, my goal is to find a way to access the value and then the address within it. Below is an example of the from json object structure:
,"from":{"value":[{"address":"admin@removed","name":"World Cafe"}],"html":"<span class=\"mp_address_group\"><span class=\"mp_address_name\">W World Cafe</span> <<a href=\"mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="59383d343037192b3c34362f3c3d773a3634">[email protected]</a>\" class=\"mp_address_email\">admin@removed</a>></span>","text":"World Cafe <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="badbded7d3d4fac8dfd7d5ccdfde94d9d5d7">[email protected]</a>>"}}"
Would appreciate any guidance or help on how to correctly access the nested json object, thank you! =]