message: fix bug where exported questionnaire would contain null items in arrays
diff: @@ -9,14 +9,20 @@ will give:
  object: {}
  }
  */
  -export const emptyPropertyReplacer = (key: string, value: unknown): unknown => {
  +const isEmptyObject = (value: unknown): boolean => {
  + return typeof value === 'object' && Object.keys(<Record<string, unknown>>value).length === 0;
  +};
  +
  +export const emptyPropertyReplacer = (_key: string, value: unknown): unknown => {
  if (value === undefined || value === null || value === '') {
  return undefined;
  }
  - if (Array.isArray(value) && value.length === 0) {
  - return undefined;
  + if (Array.isArray(value)) {
  + // remove empty objects from array (to avoid null values in arrays)
  + const filteredValue = value.filter((x) => !isEmptyObject(x));
  + return filteredValue.length === 0 ? undefined : filteredValue;
  }
  - if (typeof value === 'object' && Object.keys(<Record<string, unknown>>value).length === 0) {
  + if (isEmptyObject(value)) {
  return undefined;
  }
  return value;
  