Recipe export template from Google Sheets to JSON - Waiviogit/waivio GitHub Wiki

Set Up Script in Google Sheets

  1. Create or open a table in Google Sheets by visiting Google Drive.
  2. In the top menu, click on the Extensions tab.

image

  1. Select Apps Script.

image

  1. Give your project a name (e.g., "Export JSON").

image

  1. Delete any existing code in the script editor.

image

  1. Copy the script code from here.

image

  1. Paste the code into the script editor.

image

  1. Click the Save project button.

image

  1. Return to your table and refresh the page.

  2. You should now see a new tab in the top menu.

image

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.

image

Add Fields Template to Google Sheets

  1. Open the Google template containing the fields, and copy them to your table.

  2. 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.

image

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.

  1. Click Export JSON.
  2. Select Export JSON for this sheet.

image

  1. An "Authorization Required" modal window will appear.

image

  1. Click Continue.
  2. Complete the authorization process and grant the necessary permissions.
  3. Click Export JSON again.
  4. You should see a notification indicating that the script is running, followed by a modal window displaying the JSON.

image

image

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.

image

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.

image

Below is a table of all fields from the template.

Field Name Example Value Description
fieldBudget image The recipe budget information.
Field type: string.
fieldCalories image The recipe calories information.
Field type: string.
fieldCookingTime image The recipe cooking time information.
Field type: string.
fieldDescription image The description for this object.
Field type: string.
fieldRecipeIngredients image A list of recipe ingredients.
Each ingredient information must be separated by ";".
There is no need to put a ";" after the last URL.
Field type: array.
imageURLs image A list of image URLs (gallery items) for this link.
Each image URLs must be separated by ";".
There is no need to put a ";" after the last URL.
Field type: array.
listAssociations image 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.
name image The object's name.
Field type: string.
primaryImageURLs image The object's avatar.
Field type: array.
waivio_product_ids image A list of product IDs with value associated with this recipe. Format for recording tags:
key: Product ID type; value: Value*

Key from value must be separated by ";".
Each product ID must be separated by "*".
Value can have only one option.
Field type: nested
waivio_tags image A list of tags with tag categories associated with this recipe. Format for recording tags:
key: Category Tag Name; value: Tag*

Key from value must be separated by ";".
Each tag must be separated by "*".
Value can have only one option. Therefore, in order to add several tags to one category tag, they need to be recorded separately.
Field type: nested

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.

Links

⚠️ **GitHub.com Fallback** ⚠️