3.3.1 • Published 2 months ago

ss2json v3.3.1

Weekly downloads
12
License
MIT
Repository
github
Last release
2 months ago

node-ss2json

npm version Test

Convert Google Spreadsheet contents to JSON. Also update Google spreadsheet from JSON data.

install

% npm install ss2json

help

% ss2json --help
Usage: ss2json [options] [command]

Options:
  -V, --version     output the version number
  -h, --help        output usage information

Commands:
  get [options]
  update [options]

get

% ss2json get --help
Usage: get [options]

Options:
  -a, --auth [AUTH_JSON_FILE_PATH]  JSON path for Google's authentication
  -i, --id [SPREADSHEET_ID]         Google Spreadsheet ID
  -n, --name [SHEET_NAME]           Sheet name in Google Spreadsheet
  -h, --help

update

% ss2json update --help
Usage: ss2json update [options]

Options:
  -a, --auth [AUTH_JSON_FILE_PATH]  JSON path for Google's authentication
  -i, --id [SPREADSHEET_ID]         Google Spreadsheet ID
  -n, --name [SHEET_NAME]           Sheet name in Google Spreadsheet
  -d, --data [DATA_JSON_FILE_PATH]  JSON file path for update data
  --autoAddSheet                    Add when there was no sheet.
  -h, --help                        output usage information

Command example

Get the data from the spreadsheet and write it to data.json.

% ss2json get \
    -a AUTH_JSON_FILE_PATH \
    -i SPREADSHEET_ID \
    -n SHEET_NAME > ./data.json

You can also edit data.json to update the spreadsheet.

% ss2json update \
    -a AUTH_JSON_FILE_PATH \
    -i SPREADSHEET_ID \
    -n SHEET_NAME \
    -d ./data.json

Usage example of Node.js API

get

const ss2json = new (require('ss2json'))()

ss2json.convert({
  authJsonPath: 'JSON path for Google\'s authentication',
  spreadsheetId: 'Google Spreadsheet ID',
  sheetName: 'Sheet name in Google Spreadsheet'
}).then((data) => {
  console.log(data)
}).catch((err) => {
  console.error(err)
})

update

const ss2json = new (require('ss2json'))()

ss2json.update({
  authJsonPath: 'JSON path for Google\'s authentication',
  spreadsheetId: 'Google Spreadsheet ID',
  sheetName: 'Sheet name in Google Spreadsheet',
  values: [
    // 'Update data'
    {  key1: 'value1', key2: 'value2' },
    {  key1: 'value3', key2: 'value4' },
    ...
  ],
  autoAdd: true // If true, the sheet will be added automatically if it doesn't exist.
}).then((result) => {
  console.log(result)
})

AUTH_JSON_FILE_PATH / authJsonPath

Use GCP service account credentials. You first need to create a service account, download its json key.

3.3.1

2 months ago

3.3.0

2 years ago

3.2.16

3 years ago

3.2.15

3 years ago

3.2.13

3 years ago

3.2.14

3 years ago

3.2.12

3 years ago

3.2.11

3 years ago

3.2.10

3 years ago

3.2.9

3 years ago

3.2.8

3 years ago

3.2.7

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.14

7 years ago

0.0.10

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago