node-google-spreadsheet
node-google-spreadsheet copied to clipboard
Add toJson functionality for SpreadsheetRow objects
Functionality that would convert the instance of SpreadsheetRow to just it's data with the signature [columnname]: value would be super helpful
Good idea :)
I've just a published a new version of this module which is a complete rewrite using Google's V4 Sheets API (v3 is being deprecated on March 3, 2020). Docs available here - https://theoephraim.github.io/node-google-spreadsheet
Feel free to open a PR, and if not, I'll try to get it into the next round of improvements.
Thanks! 😄
Did this as a quick workaround with the latest node version or babel confign you can simplify it using Òbject.fromEntries instead of pushing every prop.
rows.toJson = rows.reduce((acc, row) => {
const cleanRow = {}
const rowEntries = Object.entries(row)
rowEntries.forEach(([key, value]) => {
if (key.charAt(0) !== "_") {
cleanRow[key] = value
}
})
acc.push(cleanRow)
return acc
}, [])
This is now implemented - https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-row?id=fn-toobject