I've got this result from a query :
I convert it to an object with JSON.parse. Now I Want this object to be an array of string so that it can appear in vue-formular just like this :
tag: ['tag_7z8eq73', 'tag_7v9aq73', 'tag_8gr6h5h', 'tag_5bh89vh', 'tag_0k4kl89'],
Do you know what is the right way to convert ?
CodePudding user response:
result_of_query = `[{"tag_property": ["tag_7z8eq73", "tag_7v9aq73", "tag_8gr6h5h", "tag_5bh89vk", "tag_0k4kl89"]}]`;
o = JSON.parse(result_of_query);
console.log(o[0].tag_property);
CodePudding user response:
let data = [{"key1": ["item1", "item2", "item3" ]} , {"key2": ["item1", "item2", "item3" ]}];
for(let i =0; i < data.length; i ){
for(let [key, item] of Object.entries(data[i])){
console.log(key, item)
}
}