Link export template from Google Sheets to JSON - Waiviogit/waivio GitHub Wiki
This information explains how to create a JSON file to export a Link object type from Google Sheets for importing into Waivio.
Set Up Script in Google Sheets
- Create or open a table in Google Sheets by visiting Google Drive.
- In the top menu, click on the Extensions tab.
- Select Apps Script.
- Give your project a name (e.g., "Export JSON").
- Delete any existing code in the script editor.
- Copy the script code from here.
- Paste the code into the script editor.
- Click the Save project button.
-
Return to your table and refresh the page.
-
You should now see a new tab in the top menu.
If the new tab does not appear, refresh the page once more. Alternatively, you can return to the script, add a comment (e.g., // comment), save it, then return to the table and refresh the page. Typically, the new tab will appear after the page loads.
Add Fields Template to Google Sheets
-
Open the Google template containing the fields, and copy them to your table.
-
Freeze the first row by going to View -> Freeze -> 1 row. This is important because the first row contains the field names that will be exported.
Grant Permissions to Execute the Script
The first time you click "Export JSON for this sheet," you'll need to grant permission for the script to run.
- Click Export JSON.
- Select Export JSON for this sheet.
- An "Authorization Required" modal window will appear.
- Click Continue.
- Complete the authorization process and grant the necessary permissions.
- Click Export JSON again.
- You should see a notification indicating that the script is running, followed by a modal window displaying the JSON.
About the Exported JSON Modal Window
The "Exported JSON" modal window contains:
- A direct link to download the file from your Google Drive.
- The JSON data generated by the script.
Each time the script runs, a new file is created in your Google Drive. Even if you edit the same table, a new file will be generated. Be sure to delete unnecessary files from your Google Drive periodically to manage your storage.
About Table Fields
The first row of the table contains the field names. Each subsequent row represents a separate object:
- The 2nd row corresponds to Object #1.
- The 3rd row corresponds to Object #2.
- The 4th row corresponds to Object #3. and so on.
Below is a table of all fields from the template.
Pay special attention to the field imageURLs
, as different items should be separated by a semicolon (;).
Field Name | Example Value | Description |
---|---|---|
primaryImageURLs |
The link's avatar. Field type: array. | |
fieldDescription |
The description for this link. Field type: nested. | |
imageURLs |
A list of image URLs for this link. Each image URLs must be separated by ";". There is no need to put a ";" after the last URL.Field type: array. | |
name |
The link's name.Field type: string. | |
fieldTitle |
The title for this link. Field type: string. | |
fieldUrl |
The URL value for URL link field. Field type: string. | |
listAssociations |
Permlinks of lists where the user wants to add the imported object. A permlink is a unique part of the list URL, typically found between /object and the page part of the URL. For example, in the URL https://www.waivio.com/object/34mfdx-essentials/list, the permalink is 34mfdx-essentials). Each permlink must be separated by ";". There is no need to put a ";" after the last URL.Field type: array. |
Recommendation
- Use a Google account when you don't have important files stored there. Each time the script runs, it creates a file on your Google Drive, so you'll need to clear space periodically (the script runs after you click "Export JSON for this sheet").
- Do not change the field names in the first row, as they are already correct.
- Do not change the field order or delete columns, as the script relies on the location index.
- It is not necessary to fill in all cells. Empty cells will be skipped.