google-spreadsheet-reader
Converts a Google SpreadSheet to a pretty JSON.
This works with both server server-side and client-side :)
Click here
DemoInstall
$ npm install google-spreadsheet-reader
Preparation
Publish to the web
Select [File > Publish to the web…]
Click [Publish]
Done!
Customize documents
After toggle [Published content & settings], select documents you want to publish. Then click [Start publishing]
Stop publishing
After toggle [Published content & settings], click [Stop publishing]
Usage
Example
For example, see this spreadsheet example.
Get key
Use the key
from the URL.
var SpreadSheet = ; // Create SpreadSheet Objectvar spreadSheet = '1lBbCRh6N2Ozz8oEB9fIRN4vuUNQhErqGbAQbHAu2w5Q';
Basic example:
spreadSheet // beautiful JSON! ; // Aw, something happened.
Result:
Options:
You can change the property names to camelCase by setting the camelcase
flag to true
.
spreadSheet // JSON with camelcased properties! ;
Result:
Represent data types
You can represent JSON data types with the following spreadsheet configurations.
int / float / number
Add type next to property. (e.g. Population: int
)
Array / JSON
For Array
, split items with |
(e.g. Genotype: Array
)
Object
Convert page items to 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
)