ss2json

    3.2.16 • Public • Published

    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
    

    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.

    Install

    npm i ss2json

    DownloadsWeekly Downloads

    7

    Version

    3.2.16

    License

    MIT

    Unpacked Size

    24.6 kB

    Total Files

    16

    Last publish

    Collaborators

    • abetomo