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

Support decoding structs into Go maps #79

Merged
merged 4 commits into from
Feb 15, 2024
Merged

Conversation

alexejk
Copy link
Owner

@alexejk alexejk commented Feb 14, 2024

As has been mentioned in #77, in some cases an XML-RPC struct member names are not known at compile time. This makes definitions of response datatypes much more complicated or not always possible.

To workaround this, StrDecoder can now accept map[string]any values alongside struct values.
In order to not over-complicate things a limitation on the map's key type to be a string has been added.

This new functionality should be backwards compatible as existing codebases could never use map datatypes for decoding, thus introducing additional flexibility to struct decoding won't cause any problems.

Fixes #77

@alexejk alexejk marked this pull request as ready for review February 14, 2024 20:09
Copy link

sonarcloud bot commented Feb 14, 2024

Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (2830010) 75.38% compared to head (abbf585) 75.60%.

Files Patch % Lines
decode.go 93.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
+ Coverage   75.38%   75.60%   +0.21%     
==========================================
  Files           7        7              
  Lines         524      541      +17     
==========================================
+ Hits          395      409      +14     
- Misses         99      101       +2     
- Partials       30       31       +1     

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

@alexejk alexejk added enhancement New feature or request waiting for feedback Issue pending information/response from reporter labels Feb 14, 2024
@alexejk alexejk merged commit 8c0fd9a into master Feb 15, 2024
4 checks passed
@alexejk alexejk deleted the decode-struct-as-map branch February 15, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting for feedback Issue pending information/response from reporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to decode a struct of arbitrary fields?
1 participant