{"action":"created","issue":{"url":"https://api.github.com/repos/argonaut-io/argonaut/issues/205","labels_url":"https://api.github.com/repos/argonaut-io/argonaut/issues/205/labels{/name}","comments_url":"https://api.github.com/repos/argonaut-io/argonaut/issues/205/comments","events_url":"https://api.github.com/repos/argonaut-io/argonaut/issues/205/events","html_url":"https://github.com/argonaut-io/argonaut/issues/205","id":121176191,"number":205,"title":"Loss of scale when decoding numbers","user":{"login":"carymrobbins","id":3103764,"avatar_url":"https://avatars.githubusercontent.com/u/3103764?v=3","gravatar_id":"","url":"https://api.github.com/users/carymrobbins","html_url":"https://github.com/carymrobbins","followers_url":"https://api.github.com/users/carymrobbins/followers","following_url":"https://api.github.com/users/carymrobbins/following{/other_user}","gists_url":"https://api.github.com/users/carymrobbins/gists{/gist_id}","starred_url":"https://api.github.com/users/carymrobbins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carymrobbins/subscriptions","organizations_url":"https://api.github.com/users/carymrobbins/orgs","repos_url":"https://api.github.com/users/carymrobbins/repos","events_url":"https://api.github.com/users/carymrobbins/events{/privacy}","received_events_url":"https://api.github.com/users/carymrobbins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-09T07:00:14Z","updated_at":"2015-12-09T17:20:32Z","closed_at":null,"body":"When we decode numbers, we lose the scale -\r\n\r\n```scala\r\nargonaut.Parse.parse(\"2.00\")\r\n// scalaz.\\/[String,argonaut.Json] = \\/-(2)\r\n```\r\n\r\nCompare this to Play's JSON library -\r\n\r\n```scala\r\nplay.api.libs.json.Json.parse(\"2.00\")\r\n// play.api.libs.json.JsValue = 2.00\r\n```\r\n\r\nWhile in most cases this is fine, in others we actually need this information.  For instance, if we're consuming an AST encoded in JSON, we can infer the type of this value to be `Double`.  However, the current implementation prevents this and we'd just end up inferring `Int`.\r\n\r\nI use Play as an example since it may present a possible solution.  Instead of parsing the value as `Double` it could be parsed as `scala.math.BigDecimal` (which is the underlying type of Play's `JsNumber`).  We could then do what we wish from there - inspect the scale, convert to `Int`, `Double`, etc.\r\n\r\nDoes this sound reasonable?  If so, I'd be willing to work on a PR for this."},"comment":{"url":"https://api.github.com/repos/argonaut-io/argonaut/issues/comments/163330104","html_url":"https://github.com/argonaut-io/argonaut/issues/205#issuecomment-163330104","issue_url":"https://api.github.com/repos/argonaut-io/argonaut/issues/205","id":163330104,"user":{"login":"carymrobbins","id":3103764,"avatar_url":"https://avatars.githubusercontent.com/u/3103764?v=3","gravatar_id":"","url":"https://api.github.com/users/carymrobbins","html_url":"https://github.com/carymrobbins","followers_url":"https://api.github.com/users/carymrobbins/followers","following_url":"https://api.github.com/users/carymrobbins/following{/other_user}","gists_url":"https://api.github.com/users/carymrobbins/gists{/gist_id}","starred_url":"https://api.github.com/users/carymrobbins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carymrobbins/subscriptions","organizations_url":"https://api.github.com/users/carymrobbins/orgs","repos_url":"https://api.github.com/users/carymrobbins/repos","events_url":"https://api.github.com/users/carymrobbins/events{/privacy}","received_events_url":"https://api.github.com/users/carymrobbins/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T17:20:32Z","updated_at":"2015-12-09T17:20:32Z","body":"Actually, I just built master from source and it seems it _does_ provide this feature already.\r\n\r\n```scala\r\nscala> Parse.parse(\"2\").right.get.number.get.toBigDecimal.scale\r\nres14: Int = 0\r\n\r\nscala> Parse.parse(\"2.0\").right.get.number.get.toBigDecimal.scale\r\nres15: Int = 1\r\n\r\nscala> Parse.parse(\"2.00\").right.get.number.get.toBigDecimal.scale\r\nres16: Int = 2\r\n```\r\n\r\nAlthough, it seems like some other things have changed as well, like the use of `Either` instead of `\\/`.\r\n\r\nAny idea when we'll see a release with this feature?"}}