Skip to content

Instantly share code, notes, and snippets.

@faustobdls
Created September 18, 2022 22:58
Show Gist options
  • Save faustobdls/49fcec24fb1f77d128d261f27fc85e06 to your computer and use it in GitHub Desktop.
Save faustobdls/49fcec24fb1f77d128d261f27fc85e06 to your computer and use it in GitHub Desktop.
const obj = {
list: [
{ param1: "gasgdgasdggasd", param2: 9 },
{ param1: "gasgdgasdggasd", param2: 9 },
{ param1: "gasgdgasdggasd", param2: 9 },
{ param1: "gasgdgasdggasd", param2: 9 },
{ param1: "gasgdgasdggasd", param2: 9 },
],
};
var str = "";
str =
str +
Object.keys(obj.list[0]).map((e2, i2, a2) => {
return `${e2}`;
}).join(';');
str = `${str} \n`;
str =
str +
obj.list.map((e, i, a) => {
let line = Object.values(e).map((e2, i2, a2) => {
return `${e2}`;
}).join(';');
return `${line} \n`;
}).join('');
console.log(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment