Currently, I am delving into the realm of constructing and interpreting JSON objects for a personal project centered around pet adoption. A close companion has proposed that I construct one in the following manner:
var userPets = {};
userPets['dogs'] = {};
userPets.dogs['Rex'] = {};
userPets.dogs.Rex['breed'] = 'Labrador Retriever';
userPets.dogs.Rex['age'] = '3 years old';
userPets.dogs.Rex['location'] = 'California';
userPets.dogs.Rex['notes'] = 'great with kids and other pets';
I have successfully managed to convert this object into a string, save it, retrieve it, and parse it. However, I am currently at a standstill when it comes to accessing specific pieces of information (such as age). Is it a common practice to build up the object hierarchy using dots from userPets, to userPets.dogs, to userPets.dogs.Rex? Furthermore, how can I effectively access each individual property?