I have a JSON serialized collection:
[
{
"_id":"person1",
"date":"7/20/2014 17:20:09",
"listed_name":"Tom",
"name":"Tom",
"contact_info":"tom@gmail.com"
},
{
"_id":"person2",
"date":"7/20/2014 17:20:09",
"listed_name":"Jane",
"name":"Jane",
"contact_info":"Person2@gmail.com"
},
{
"_id":"person3",
"date":"7/20/2014 17:20:09",
"listed_name":"John",
"name":"John",
"contact_info":"Person3@gmail.com"
}
]
And property name information coming from another page...
["_id", "date", "listed_name"]
The questions is...
Using JavaScript, how can I use the second array as a filter to return only the columns contained in the second array?
For instance: using this array ["_id"]
... how can this array be used to only show the _id
data for all JSON objects but keep out date
, listed_name
, name
, etc...?
With the ["_id"]
array as a filter, the expected console output should look like this:
person1
person2
person3