-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Object wrappers for primitives may not be stringified correctly #236
Comments
That's a difference from the behaviour of I don't really see that it'd be beneficial to enable the current incorrect and surprising behaviour with an option. |
Yeah, they're effectively special-cased by the spec. In addition to these specific three, there's also the object form of BigInt that's unwrapped to a primitive when stringifying. I for one had no idea that even existed before now. I mean, if you try * This is a lie. I actually have a potential use case for exactly this, but I'm trying very hard not to think about it too much, because it'd mean rewriting also the front-end of this library. This bug report has actually provided me with a core missing piece of that idea. |
Thank you @MikeRalphson, this should be fixed now. I'm very happy for this to have come up during the v2 transition, as it means that I don't need to figure out if this counts as a breaking change or not. |
Describe the bug
JavaScript types
Boolean
,Number
andString
(wrappers for primitive types) are stringified very differently to in JSON when invoked withnew
.To Reproduce
Expected behaviour
not
Versions (please complete the following information):
yaml
: 2.0.0-3Additional context
JSON.stringify
returns{"enum":["mystring"],"bool":false,"num":123}
Unsure if this is really a bug in the default operation, or whether the behaviour could be controlled via an option. Does not happen when the
new
keyword is not used.The text was updated successfully, but these errors were encountered: