Error in Json to Protobuf conversion using JsonFormat

107 views
Skip to first unread message

Akash Koradia

unread,
Nov 28, 2020, 1:44:09 PM11/28/20
to Protocol Buffers
Hello,
I am new in protobuf and I am using Protobuf with Retrofit in android - Kotlin
I have a message class Called OtpResponse 

syntax = "proto3";

package model;

option java_package = "com.example.protobufdemonstration.model";
option java_multiple_files = true;

message OtpResponse {
bool status = 1;
}


When I get any repsonse from retrofit then I convert that Jsonto OtpResponse Class using JsonFormat .parser().merge() function. Below is the code that i have written for conversion:

val builder = OtpResponse.newBuilder()
JsonFormat.parser().ignoringUnknownFields().merge(jsonObject.toString(), builder)

But In above response I am getting error in Merge Function Saying that 

None of the following functions can be called with the arguments supplied.
merge(Reader!, Message.Builder!)
merge(String!, Message.Builder!) 

How can I solve this error. Please help!!

Thanks, 
Akash Koradia 

Reply all
Reply to author
Forward
0 new messages