ファイルに保存しときたいけど、毎回忘れてしまうやつ。
PropertiesService
クラスのgetScriptProperties()
を使用することでスクリプトプロパティの内容を取得できる。
jsonにするのはJSON.stringify()
を使ってjson文字列にすることができます。
const properties = PropertiesService.getScriptProperties().getProperties();
console.log(JSON.stringify(properties))
ちなみに、jsonファイルをGoogle Driveに保存するには、
DriveApp
クラスを使うことで可能です。
const properties = PropertiesService.getScriptProperties().getProperties();
const jsonStr = JSON.stringify(properties);
// 保存
const folder = DriveApp.getFolderById('<<フォルダID>>'); //フォルダIDを指定
folder.createFile('property.json', jsonStr, MimeType.PLAIN_TEXT);
createFile()
で新規にファイルを保存してみました。