scalapb-json / scalapb-circe

Json/Protobuf convertors for ScalaPB use circe
MIT License
43 stars 11 forks source link

Deserializing Array field throws exceptions #73

Open ArulselvanMadhavan opened 3 years ago

ArulselvanMadhavan commented 3 years ago
message EcpmA {
  required string dummy = 1;
}
message EcpmR {
    required string meta = 1;
    repeated EcpmRequestAdvertiserMessage checks = 2 [(scalapb.field).collection_type="Array"];
}
    import scalapb_circe.json._
    val er = EcpmR(meta, Array(EcpmA("something")))
    println(s"${er.asJson}")

scalapb version=0.10.0 scalapb_circe version = 0.7.1

Exception

[E] Exception in thread "main" scalapb_json.JsonFormatException: [Lcom.chartboost.adrel.models.messages.InterfaceMessages.EcpmRequestAdvertiserMessage;@4218d6a3
[E]     at scalapb_circe.Printer.serializeMessageField(JsonFormat.scala:117)
[E]     at scalapb_circe.Printer.$anonfun$toJson$1(JsonFormat.scala:159)
[E]     at scala.collection.Iterator.foreach(Iterator.scala:943)
[E]     at scala.collection.Iterator.foreach$(Iterator.scala:943)
[E]     at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[E]     at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[E]     at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[E]     at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[E]     at scalapb_circe.Printer.toJson(JsonFormat.scala:156)
[E]     at scalapb_circe.JsonFormat$.$anonfun$protoToEncoder$1(JsonFormat.scala:460)
[E]     at io.circe.Encoder$$anon$3.apply(Encoder.scala:127)
[E]     at io.circe.syntax.package$EncoderOps$.asJson$extension(package.scala:10)
[E]     at com.chartboost.adrel.serving.Main$.main(Main.scala:1020)
[E]     at com.chartboost.adrel.serving.Main.main(Main.scala)
ArulselvanMadhavan commented 3 years ago

The same code works with List