Converts a Google SpreadSheet to a pretty JSON.
Demo Click here
$ npm install google-spreadsheet-reader
Select [File > Publish to the web…]
Click [Publish]
Done!
After toggle [Published content & settings], select documents you want to publish. Then click [Start publishing]
After toggle [Published content & settings], click [Stop publishing]
For example, see this spreadsheet example.
Use the key
from the URL.
var SpreadSheet = require('google-spreadsheet-reader');
// Create SpreadSheet Object
var spreadSheet = new SpreadSheet('1lBbCRh6N2Ozz8oEB9fIRN4vuUNQhErqGbAQbHAu2w5Q');
spreadSheet.load()
.then(function(res) { console.log(res); }) // beautiful JSON!
.catch(function(err) { console.error(err.message); }); // Aw, something happened.
Result:
You can change the property names to camelCase by setting the camelcase
flag to true
.
spreadSheet.load({ camelcase: true })
.then(function(res) { console.log(res); }) // JSON with camelcased properties!
.catch(function(err) { console.error(err.message); });
Result:
You can represent JSON data types with the following spreadsheet configurations.
Add type next to property. (e.g. Population: int
)
For array
, split items with |
(e.g. Genotype: array
)
You can create an object
type and with the first column, define its properties.
Add : object
next to the first property. (e.g. id: object
)