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

JsNumber in JsonNodes #8

Open
alexander-myltsev opened this issue Feb 8, 2015 · 0 comments
Open

JsNumber in JsonNodes #8

alexander-myltsev opened this issue Feb 8, 2015 · 0 comments

Comments

@alexander-myltsev
Copy link
Owner

JsNumber should be of BigDecimal when scala-js would support it.

  case class JsNumber(value: BigDecimal) extends JsValue
  object JsNumber {
    def apply(n: Int) = new JsNumber(BigDecimal(n))
    def apply(n: Long) = new JsNumber(BigDecimal(n))
    def apply(n: Double) = n match {
      case n if n.isNaN => JsNull
      case n if n.isInfinity => JsNull
      case _ => new JsNumber(BigDecimal(n))
    }
    def apply(n: BigInt) = new JsNumber(BigDecimal(n))
    def apply(n: String) = new JsNumber(BigDecimal(n))
    def apply(n: Array[Char]) = new JsNumber(BigDecimal(n))
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant