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

chore: implement encoding.Unmarshal #975

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

worstell
Copy link
Contributor

@worstell worstell commented Feb 23, 2024

fixes #971
fixes #951

@worstell worstell force-pushed the worstell/20240222-add-encoding-unmarshal branch from e7d8bf8 to 8606043 Compare February 23, 2024 02:37
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Good start, but this needs some tests.

v = v.Elem()
fallthrough

case t.Implements(jsonUnmarshaler):
case t.Implements(jsonMarshaler):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch 🤦‍♂️

if _, ok := jsonData[jsonKey]; ok {
fieldTypeStr := fieldType.Type.String()
switch {
case fieldTypeStr == "*Unit" || fieldTypeStr == "Unit":
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be a direct comparison with reflect.TypeOf(ftl.Unit{}) et al?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this introduces a dependency cycle because ftl depends on encoding (it's used in option.go)

Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Would it be better to use the streaming JSON decoder?

@worstell worstell force-pushed the worstell/20240222-add-encoding-unmarshal branch 2 times, most recently from 6af7298 to 6a2bfec Compare February 23, 2024 20:49
@worstell worstell requested a review from alecthomas February 23, 2024 20:53
@worstell worstell force-pushed the worstell/20240222-add-encoding-unmarshal branch from 6a2bfec to 8a7617c Compare February 23, 2024 21:59
@worstell
Copy link
Contributor Author

Would it be better to use the streaming JSON decoder?

good idea! updated

Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Nice!

@worstell worstell force-pushed the worstell/20240222-add-encoding-unmarshal branch from 8a7617c to e83e33b Compare February 23, 2024 22:06
@worstell worstell merged commit 0639b89 into main Feb 23, 2024
11 checks passed
@worstell worstell deleted the worstell/20240222-add-encoding-unmarshal branch February 23, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants