-
Notifications
You must be signed in to change notification settings - Fork 10
Remove the .to[X] converters #17
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
Comments
I'm 👍 on this—as I've noted before, this piece of ScalaJSON seems to be mixing decoding concerns in a project that's otherwise (usefully) focused solely on providing a JSON representation. |
+1, same reasoning as @travisbrown - let this lib be as focused on "just-the-representation" as possible. |
I have a contrary view. There are very few possible correct ways to convert a JSON number into some other representation, and it's often hard to do it right. If you don't do it for people, they'll do it wrong and things will break, and not because they wanted different behavior. There isn't any other sensible behavior; it's numbers! Thus, the AST should handle the conversions to common types. It shouldn't do this in ways that are difficult to make reliable and/or performant (e.g. there should not only be methods that throw exceptions if things are out of range), but it should do them. In cases where there are a variety of plausibly correct ways to do things, then the AST should remain agnostic. This is not one of those cases. |
@Ichoran I have removed the the I am open to adding them back in, along with the following design decisions
The current implementation didn't do any of these If someone can submit a PR that does this, I would be happy to include it if it follows the above points. We have some inspiration from argonaut here https://github.com/argonaut-io/argonaut/blob/master/argonaut/shared/src/main/scala/argonaut/JsonNumber.scala to do this. |
Uh oh!
There was an error while loading. Please reload this page.
Currently scalajson has various
.to[X]
i.e..to[BigDecimal]
converters, mainly used by JNumber. Over time I have been forming the opinion that they should be removed, reasons are.to[BigDecimal]
on a number with a really big exponent, issue with some libraries that really value correctness, i.e. circe Integration with ScalaJSON circe/circe#690 (comment))JNumber
?). The AST is designed to be trivial as possibleAny objections?
The text was updated successfully, but these errors were encountered: