I have inherited a project and need to recreate an object in this format (dynamically) but have not sure how to do it. This is what I tried and it's almost there:
//this creates [{ "Country": ["Canada", "United States of America"] }]
filters = [];
var object = {};
object.Country = [];
object.Country.push('Canada', 'United States of America');
filters.push(object);
//alert(JSON.stringify(filters));
console.log(JSON.stringify(filters));
//currently getting this
//filters = [{ "Country": ["Canada", "United States of America"] }]
//need this
//filters = { 'Country': ['Canada', 'United States of America'] };
I have a form where the user will select the column in a table (Country) and then enter one or more countries. Currently the filter works based on the hard coded object above. I need to now change the object on the fly for other columns.
Any help would be much appreciated.