Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined is missing from exported JSON #7

Open
nkooman-bzs opened this issue Sep 12, 2024 · 1 comment
Open

undefined is missing from exported JSON #7

nkooman-bzs opened this issue Sep 12, 2024 · 1 comment
Assignees
Labels

Comments

@nkooman-bzs
Copy link
Contributor

nkooman-bzs commented Sep 12, 2024

Brief bug description

When data is exported any fields that are set to undefined will not be present in the resulting JSON output.

Repro steps

  1. Export a content item that includes an empty field
    • Ex: Non-required number element or text element
  2. Run the export command
  3. See that the value field does not exist

Expected behavior

The value field has a value.

Test environment

N/A

Additional context

undefined is not a valid value per the JSON specification.

The import will gracefully handle a missing value field. Accessing data.value when value is missing still results in undefined.
However, this can cause issues when a user wishes to directly interact with the exported JSON, expecting the value field to exist. Also, values of 0 and an empty string will not be imported correct, resulting in incorrect migrations.

I believe the fix to this issue would be to use null instead of undefined to represent an empty field.

Screenshots

image

@Enngage
Copy link
Member

Enngage commented Dec 11, 2024

Hi @nkooman-bzs,

This was an intentional choice to use undefined as it makes the output json less verbose. While the null would be preserved in json I'm not quite sure if we want to make this breaking change.

I'm open to revisit this topic in future, but for now I don't think we'll pursue this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants