[Solved] Turn json object value become a key and value in javascript [closed]
You can use Object.fromEntries(): const obj = [ { “configSlug”: “receiptStoreName”, “configContent”: “The Store Name” }, { “configSlug”: “receiptStoreAddress”, “configContent”: “Cattle Street” }, { “configSlug”: “receiptStorePhone”, “configContent”: “01 123234” }, { “configSlug”: “receiptStoreFoot1”, “configContent”: “Thanks For Visiting” } ]; const result = Object.fromEntries(obj.map(entry => [entry.configSlug, entry.configContent])); console.log(result); Or you can use a simple loop: const … Read more