0

I am trying to convert List[Map[String, Any] to Option[com.google.protobuf.struct.Struct] using Scalapb:

Proto:

message IOTDecodeRequest {
  string id = 1;
  string user_id = 2;
  bytes raw_data = 3;
}

message DecodeResult {
  google.protobuf.Struct decoded = 1;
}

I need to store:

 val rawdata: List[Map[String, Any]] =
   List(
     Map("Userid" -> 860267, "height " -> 0.062),
     Map("userid" -> 860268, "height " -> 0.062)
   )

into DecodeResult using Scala.

How can I do the conversion?

Xavier Guihot
  • 54,987
  • 21
  • 291
  • 190
sonia
  • 29
  • 5
  • You should also provide your input! – AminMal Jul 25 '22 at 06:54
  • And avoid using `Any`. It can hold: primitives, Unit (void), nulls, and virtually any objects: normal classes, sealed traits, anonymous classes. It is virtually impossible tell what you have there. If raw data are bytes, then I suggest storing there something which represents bytes. – Mateusz Kubuszok Jul 25 '22 at 08:44
  • input is bytes which i will decode and the result will be in the form of List[Map[string,Any]], which is for example : List( Map("Userid" -> 860267, "height " -> 0.062), Map("userid" -> 860268, "height " -> 0.062) ) – sonia Jul 25 '22 at 10:24

0 Answers0