Skip to content

feat: add support for serialization options dropNull and dropDefault #97

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

esafak
Copy link

@esafak esafak commented Jul 30, 2025

  • Introduced SerializationOptions object with dropNull and dropDefault fields.
  • Updated toJson and dumpHook procedures to accept options parameter.
  • Implemented shouldDropNull to determine if a value should be omitted.
  • Modified object dumping to skip fields with null or default values based on options.
  • Enhanced dumpHook for objects and tuples to respect dropNull and dropDefault.
  • Added tests verifying behavior with different serialization options.
  • Improved code readability and consistency in JSON serialization logic.
  • Completed some half-implemented existing tests

Closes #49

Note

  • I suggest incrementing the version to avoid breaking clients.
  • Master is broken for me; I had to fix several existing tests

- Introduced `SerializationOptions` object with `dropNull` and `dropDefault` fields.
- Updated `toJson` and `dumpHook` procedures to accept options parameter.
- Implemented `shouldDropNull` to determine if a value should be omitted.
- Modified object dumping to skip fields with null or default values based on options.
- Enhanced `dumpHook` for objects and tuples to respect dropNull and dropDefault.
- Added tests verifying behavior with different serialization options.
- Improved code readability and consistency in JSON serialization logic.

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

Successfully merging this pull request may close these issues.

Leave out object fields that have a null value
1 participant