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
Member

@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
Member

@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
Co-authored-by: Brian Flad <bflad417@gmail.com>
@bendbennett bendbennett merged commit 71dfab6 into main Jul 28, 2022
@bendbennett bendbennett deleted the bendbennett/issues-212 branch July 28, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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