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

Allow ignoring undefined attributes during unmarshalling #213

Merged
merged 4 commits into from
Jul 28, 2022

Conversation

bendbennett
Copy link
Contributor

Closes: #212

An error is generated when unmarshalling JSON that contains fields that do not have a corresponding attribute.

This PR adds an additional function, UnmarshalWithOpts that allows supplying of options that modify unmarshalling behaviour. Specifically, ignoring of undefined attributes is configurable.

@bendbennett bendbennett requested a review from a team as a code owner July 27, 2022 07:25
of opts which can be used to modify the unmarshalling behaviour,
such as ignoring undefined attributes (#212)
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks really good -- just a few minor things to tidy up and I think we'll be good to go!

tftypes/value_json.go Outdated Show resolved Hide resolved
tftypes/value_json.go Outdated Show resolved Hide resolved
tftypes/value_json.go Outdated Show resolved Hide resolved
tftypes/value_json_test.go Show resolved Hide resolved
tfprotov5/state.go Outdated Show resolved Hide resolved
@bflad bflad added this to the v0.13.0 milestone Jul 27, 2022
@bflad bflad self-assigned this Jul 27, 2022
@bflad bflad added the enhancement New feature or request label Jul 27, 2022
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just two little bitty things to consider 🚀

.changelog/213.txt Outdated Show resolved Hide resolved
tftypes/value_json.go Outdated Show resolved Hide resolved
@bendbennett bendbennett merged commit 71dfab6 into main Jul 28, 2022
@bendbennett bendbennett deleted the bendbennett/issues-212 branch July 28, 2022 15:06
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unmarshal should ignore elements in JSON that do not have a corresponding attribute
2 participants