{ "nodes": [ { "name": "Read the table by GET", "type": "n8n-nodes-base.webhook", "position": [ 100, 240 ], "parameters": { "authentication": "none", "httpMethod": "GET", "path": "google-sheet-table-json-api", "responseMode": "lastNode", "responseData": "allEntries", "options": { "responseCode": 200, "responseContentType": "application/json; charset=utf-8" } }, "typeVersion": 1, "id": "google-sheet-table-json-api-webhook" }, { "name": "Read the problem table", "type": "n8n-nodes-base.googleSheets", "position": [ 340, 240 ], "parameters": { "authentication": "serviceAccount", "resource": "sheet", "operation": "read", "sheetId": "YOUR_SPREADSHEET_ID", "range": "Problems!A:D", "rawData": true, "dataProperty": "values", "keyRow": 0, "dataStartRow": 1, "options": { "valueRenderMode": "UNFORMATTED_VALUE", "continue": false } }, "typeVersion": 1, "id": "google-sheet-table-json-api-read" }, { "id": "google-sheet-table-json-api-rows", "name": "Build table rows from headers", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 580, 240 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "function sheetTableRows({ values }) {\n if (!Array.isArray(values) || values.some(row => !Array.isArray(row))) throw new Error('Expected the sheet range as rows of cell values');\n for (const row of values) for (const cell of row) if (cell !== null && typeof cell !== 'string' && typeof cell !== 'boolean' && !(typeof cell === 'number' && Number.isFinite(cell))) throw new Error('The sheet returned an invalid cell value');\n if (!values.length) return { rows: [] };\n const headers = values[0], rows = [];\n for (const cells of values.slice(1)) {\n const row = Object.create(null);\n for (let column = 0; column < cells.length; column++) {\n const header = headers[column];\n if (header) row[String(header)] = cells[column];\n }\n if (Object.keys(row).length) rows.push(row);\n }\n return { rows };\n}\n\nconst items=$input.all();if(items.length===0)return [];if(items.length!==1)throw new Error(\"Expected one complete sheet range\");return sheetTableRows({values:items[0].json.values}).rows.map(row=>({json:row}));" } } ], "connections": { "Read the table by GET": { "main": [ [ { "node": "Read the problem table", "type": "main", "index": 0 } ] ] }, "Read the problem table": { "main": [ [ { "node": "Build table rows from headers", "type": "main", "index": 0 } ] ] } }, "name": "Google Sheet Table JSON API", "settings": { "executionOrder": "v1" }, "active": false, "pinData": {} }