I am trying to create some script which will take a Object and then return a list of all keys in that Object which works for two level keys. But once the key has another object or the Key is an Array holding Objects the script no longer returns the keys. Is there a simple way to do this or will I have to manually loop thru all keys and check if there is another object? Below is a sample object. In my case I don't care about the values but I need all keys:
object1 = {
DocId: "email_campaign::3ed76589-4063-49f6-a21e-9ca16981d102",
_id: "3ed76589-4063-49f6-a21e-9ca16981d102",
_type :"email_campaign",
end_date: "",
history: {
created_by: "",
created_on: "",
update_on: "",
updated_by: ""
},
librarys :[{id: 1, name : 'Lib 1'},{ id: 2, name: 'Lib 2'}],
metrics : {
first_email_sent: "",
last_email_send: "",
nbr_of_attachments_opened: 0,
nbr_of_bounces: 0,
nbr_of_email_opened: 0,
nbr_of_emails: 0,
nbr_of_unique_attachments_opened:0,
nbr_of_unique_email_opened: 0
},
start_date: "",
status: "Active",
subject: "Test 1 Subject",
summary: "",
tags: ['one', 'two'],
template_id: ""
};