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

Serializer also serializes properties in object prototype #31

Open
luisgabrielroldan opened this issue Feb 1, 2023 · 1 comment
Open

Comments

@luisgabrielroldan
Copy link

Looks like a for loop is used for iterating the properties in the objects

for (let key in data) {
	if (data[key] !== undefined) {
		length++;
	}
}

This also iterates the properties defined in prototypes which I don't think is an expected behaviour.

The current typescript version of msgpack is using Object.keys that does not returns those properties.

What do you think?

@ygoe
Copy link
Owner

ygoe commented Feb 1, 2023

I'm not using prototypes in that area IIRC. So I don't have a strong opinion here. I think I've seen the JSON serializer in .NET also regarding inherited properties, which would roughly translate to the current behaviour regarding the prototype. But if most users agree that this change should be done, then I'm up for it. Maybe let's have a vote on this issue? (But the visitors volume here is generally rather low.)

One question might be whether this is a breaking change or merely a bugfix.

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

No branches or pull requests

2 participants