jvican/dijon

classCastException

cocodrino opened this issue · 2 comments

Hi...If I run this

val (name, age) = ("Tigri", 7)
val cat = json"""
  {
    "name": "$name",
    "age": $age,
    "hobbies": ["eating", "purring"],
    "is cat": true
  }
"""

cat.age.as[Int].getOrElse(2)

I get an error...cat.age.as[Int] has the type Option[Int]...so is pretty weird behaviour...what could be the best option for get a json field and pass as paramete to a method..because this works

cat.age == 7

but this doesnt:

cat.age * 2

(maybe related) It's funny how assemble method does not match for Int type

I just discovered it doesn't have to do with dijon but with Scala JSon library.
Check this out: http://stackoverflow.com/questions/18945949/is-it-possible-to-make-scalas-json-parsefull-not-to-treat-integers-as-decimal