code: function fixEventPayload(events) {
      return new Promise(function (resolve, reject) {
          events.forEach(function(event) {
              try {
                  event.payload = JSON.parse(event.payload);
              } catch (e) {
                  console.log('Could not parse payload');
                  return reject(new Error('Could not parse payload: ' + e.message));
              }
          });
          resolve();
      });
  }
docs: Convert PubSub event payloads into proper nested JSON