Hi,

I want to convert any protocol buffer to json.
My protocol buffer looks as below.
```
syntax = "proto3";

message A {
   int32 id = 1;
}

message B {
   int32 id = 2;
}

message C {
   int32 id = 3;
}
```
I am converting each of them as follows using JsonFormat:
```
String jsonString;
A.Builder Abuilder = A.newBuilder();
JsonFormat.parser().ignoringUnknownFields().merge(jsonString, builder);
A a = Abuilder.build();

Similarly for B
B.Builder Bbuilder = B.newBuilder();
JsonFormat.parser().ignoringUnknownFields().merge(jsonString, builder);
B b = Bbuilder.build()
```

I wanted to know if I can write a generic method using template or java 
generics or using ```com.google.protobuf.Message``` so that I don't have to 
write the same method for each of my protocol buffer.

Thanks,
Stephanie

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/643e7d65-c1b6-417d-aaa5-047881d7356an%40googlegroups.com.

Reply via email to