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

Converting the result List[MAp[String,Any]] into scala.Option[com.google.protobuf.struct.Struct] #1390

Closed
Sumiya92 opened this issue Jul 25, 2022 · 3 comments

Comments

@Sumiya92
Copy link

Hi Team,

i have proto file

message IOTDecodeRequest {
string id = 1;
string device_id = 2;
string device_parser_id = 3;
bytes raw_data = 4;
}

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

message IOTDecodeResponse {
int32 status = 1;
string id = 2;
IOTDecodeResult result = 3;
IOTDecodeError error = 4;
}

message IOTDecodeError {
int32 code = 1;
string message = 2;
string details = 3;
}

message IOTDecodeRequests {
repeated IOTDecodeRequest requests = 1;
}

message IOTDecodeResponses {
repeated IOTDecodeResponse responses = 2;
}

service IoTDecoderService {
rpc Decode(IOTDecodeRequests) returns (IOTDecodeResponses);
}

Am trying to implement the serviceImpletation for the data using proto:

i have result of raw_data from IOTDecodeRequest as List[Map[String,Any]] i need to convert it and pass it IOTDecodeResult as google.protobuf.Struct decode
for example :
val rawdata : List[Map[String,Any]] = List(Map("deviceid" -> 860267 , "altitude " -> 0.062),Map("deviceid" -> 860268 , "altitude " -> 0.062))

Please suggest on how to convert it or is there any way to convert it

@thesamet
Copy link
Contributor

thesamet commented Jul 25, 2022

Hi @Sumiya92 , it should be fairly straightforward to write a function on your own that iterates over the input and returns a Struct. I encourage you to try writing it :)

@Sumiya92
Copy link
Author

Sumiya92 commented Jul 25, 2022

Hi @thesamet ,i have written a function for iterating the input but my question was really to construct struct value in scala , am passing Map[string,Any] but the struct required Map[string,Value] , i could not find any examples. any suggestions would be helpful.

@thesamet
Copy link
Contributor

thesamet commented Jul 25, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants