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

feat(go): register exported properties as callbacks #4104

Merged
merged 3 commits into from
May 16, 2023

Conversation

RomainMuller
Copy link
Contributor

When passing arbitrary structs through an interface{} type, the JS value had no properties or methods, leading to it having an empty object JSON representation.

In order to improve the situation, discover exported properties of such structs, and register them as property callbacks, more closely matching the behavior of JS in the same configuration.

The callbacks use the same naming transformation as the standard JSON serialization mechanism in go: using the json tag if present with the same semantics as encoding/json, and fall back to the raw field name otherwise (with no case conversion applied).

Related: cdk8s-team/cdk8s#1326


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When passing arbitrary structs through an `interface{}` type, the JS
value had no properties or methods, leading to it having an empty object
JSON representation.

In order to improve the situation, discover exported properties of such
structs, and register them as property callbacks, more closely matching
the behavior of JS in the same configuration.

The callbacks use the same naming transformation as the standard JSON
serialization mechanism in go: using the `json` tag if present with the
same semantics as `encoding/json`, and fall back to the raw field name
otherwise (with no case conversion applied).

Related: cdk8s-team/cdk8s#1326
@mergify
Copy link
Contributor

mergify bot commented May 16, 2023

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label May 16, 2023
@mergify
Copy link
Contributor

mergify bot commented May 16, 2023

Merging (with squash)...

@mergify
Copy link
Contributor

mergify bot commented May 16, 2023

Merging (with squash)...

@mergify
Copy link
Contributor

mergify bot commented May 16, 2023

Merging (with squash)...

@mergify mergify bot merged commit fa921ec into main May 16, 2023
@mergify mergify bot deleted the rmuller/go-arbitrary-struct branch May 16, 2023 21:26
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants