amnaredo / test

0 stars 0 forks source link

Invalid$Data: Tagged Object scala.collection.immutable.List #266

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago

upickle version - 0.4.4

When trying to read a nested case class, I'm getting this error of this form

upickle.Invalid$Data: Tagged Object scala.collection.immutable.List (data: [
    {
        "elements": [
            {
                "attributeName": "xyz",
                "attributeType": {
                    "$type": "******"
                },
                "attributeValue": {
                    "$type": "******",
                    "value": "3"
                },
                "attributeValueString": "3"
            }
        ]
    }
])

upickle.Implicits$Internal$$anon$1$$anonfun$apply$1.apply(Implicits.scala:83)
  upickle.Implicits$Internal$$anon$1$$anonfun$apply$1.apply(Implicits.scala:83)
  scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
  upickle.Types$Reader$$anon$2.applyOrElse(Types.scala:103)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:83)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:80)
  upickle.Types$Reader$$anon$2.apply(Types.scala:112)
  upickle.Types$Reader$$anon$2.apply(Types.scala:103)
  upickle.Types$class.readJs(Types.scala:160)
  upickle.default$.readJs(Api.scala:25)
  upickle.default$.readJs(Api.scala:25)
  upickle.Generated$$anonfun$Tuple3R$1.applyOrElse(Generated.scala:31)
  upickle.Generated$$anonfun$Tuple3R$1.applyOrElse(Generated.scala:31)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:83)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:80)
  scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
  upickle.Implicits$Internal$$anon$1.applyOrElse(Implicits.scala:80)
  upickle.Types$Reader$$anon$2.apply(Types.scala:113)
  upickle.Types$Reader$$anon$2.apply(Types.scala:103)
  upickle.Implicits$$anonfun$CaseR$1.applyOrElse(Implicits.scala:120)
  upickle.Implicits$$anonfun$CaseR$1.applyOrElse(Implicits.scala:119)
  upickle.Types$Reader$$anon$2.apply(Types.scala:113)
  upickle.Types$Reader$$anon$2.apply(Types.scala:103)
  scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
  upickle.Types$Reader$$anon$2.applyOrElse(Types.scala:103)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:83)
  upickle.Implicits$Internal$$anon$1.apply(Implicits.scala:80)
  scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
  upickle.Implicits$Internal$$anon$1.applyOrElse(Implicits.scala:80)
  upickle.Types$Reader$$anon$2.apply(Types.scala:113)
  upickle.Types$Reader$$anon$2.apply(Types.scala:103)
  upickle.Types$class.readJs(Types.scala:160)
  upickle.default$.readJs(Api.scala:25)
  upickle.Types$class.read(Types.scala:156)
  upickle.default$.read(Api.scala:25)
  ammonite.$sess.cmd11$.<init>(cmd11.sc:1)
  ammonite.$sess.cmd11$.<clinit>(cmd11.sc)

pseudocode of what I'm trying to do

case class MyClass(
schema: MyClass1, 
data:List[MyClass2], 
stringField:String,
)

val obj = MyClass(...)
val str = upickle.default.write(obj)
val obj1 = upickle.default.read[MyClass](str) 

Quite strangely, if I remove the 3rd field (stringField), it works fine.

ID: 307 Original Author: ghost

amnaredo commented 3 years ago

0.4.4 is quite old. There have been significant changes since then. Is this the issue reproducible on the latest version? Original Author: htmldoug