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

Fix decoding into struct with new fields #9

Merged
merged 9 commits into from
Jun 25, 2021
Merged

Conversation

jazg
Copy link
Member

@jazg jazg commented Jun 24, 2021

This fixes an issue where an encoded struct cannot be decoded into a struct containing new fields. For example, if we encode the following object:

type A struct {
    Foo pack.String `json:"foo"`
}

And later introduce a new field to the struct A:

type A struct {
    Foo pack.String `json:"foo"`
    Bar pack.Bytes  `json:"bar"`
}

We will be met with the following error when decoding the original encoded value into the new object: decoding \"Bar\": unexpected value of type <nil>. To resolve this, we simply skip the decoding process if the struct field is nil.

@jazg jazg requested a review from loongy June 24, 2021 02:04
loongy
loongy previously approved these changes Jun 24, 2021
Copy link
Member

@tok-kkk tok-kkk left a comment

Choose a reason for hiding this comment

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

Approved

@jazg jazg merged commit 1dd5ac4 into master Jun 25, 2021
@jazg jazg deleted the fix/encoding-nil-list branch June 25, 2021 01:27
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.

3 participants