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

Include empty arrays for components/inputs/outputs on JSON Serialize #78

Closed
wants to merge 2 commits into from

Conversation

peterbroadhurst
Copy link
Contributor

@peterbroadhurst peterbroadhurst commented Sep 8, 2024

Currently (per the included unit test) if you have an empty components array "components": [] on serialization to JSON we remove this array. This make processing the structure downstream more complex.

Sadly Golang doesn't let you omit null, but include the empty array - omitempty zaps both of them (encoding/json/v2 will solve it if it comes along).

So this PR proposes we are more verbose on serialization and always include "components":null rather than when we round-trip an omitted array, and "components":[] when we round-trip an empty array.

This makes components consistent with inputs and outputs.

Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Copy link

codecov bot commented Sep 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.64%. Comparing base (1e4fa5d) to head (9ca6e2b).
Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
+ Coverage   99.62%   99.64%   +0.01%     
==========================================
  Files          39       40       +1     
  Lines        3474     3650     +176     
==========================================
+ Hits         3461     3637     +176     
+ Misses         13       12       -1     
- Partials        0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterbroadhurst
Copy link
Contributor Author

peterbroadhurst commented Sep 8, 2024

Decided to close this and work around it in my consuming code... it is a weird behavior, but there's tests in various places that break if you change it - because they expect to be able to round trip omitted components.

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.

1 participant