toJSON() {
    // Construct a generic object with the values of this object, but with the
    // proper formatting.
    const raw = {};
    for (const key in this) {
      if (key.startsWith('preload') || key.startsWith('store') ||
          key.endsWith('Callback')) {
        // These values shouldn't be saved, as they are dynamic.
        continue;
      }
      const value = this[key];
      if (value instanceof Map) {
        // The built-in JSON functions cannot convert Maps; this converts Maps
        // to objects.
        const replacement = {};
        replacement['__type__'] = 'map';
        for (const entry of value.entries()) {
          replacement[entry[0]] = entry[1];
        }
        raw[key] = replacement;
      } else {
        raw[key] = value;
      }
    }
    return raw;
  }
@return {!Object}
@override
@suppress {checkTypes}
Suppress checkTypes warnings, so that we can access properties of this
object as though it were a struct.