So I have loaded a JSON object from D3 and now want to filter out some columns from the array. My only problem is that doing:
Object.attribute;
doesn't return what I want. The structure of my JSON object is as follows. It holds 1000 objects and each array hold attributes inside of it. I am getting my data from https://data.raleighnc.gov/resource/xce4-kemu.json, for reference.
If I do
Object[0].attribute;
It returns the actual value of the object, so like "12". Where as I want it to return all the values where that key is present
In the URL you can see an example of the JSON. I want to, for example return a JSON where only the issueddate_mth, statelicnum, and constcompletedofficial attributes are present.
An Snippet of what I tried is:
var raleigh_data = "https://data.raleighnc.gov/resource/xce4-kemu.json";
d3.json(raleigh_data, function(error, data) {
var filtered_data = data.filter(function(d,i,e) {
return d.issueddate_mth;
});
}
var filteredArray = xxx.filter(callbackFunction)to filter an array (the array in this case is a var called xxx ... you dont want to use a var calledObject) ... callbackFunction is a function that accepts 3 arguments, the item, the index and the whole array ... do your logic and return true or false to include/exclude the item in the new array returned