Hi,

I' ve got a problem to create dynamic message from JSON.

I want to use that message to send it through the MannagedChannel using the 
command 'newCall()'


Here is my progress:


File file = new File("/path/to/api_descriptor.pb");

byte[] payload = ByteStreams.toByteArray(new FileInputStream(file));

ExtensionRegistry registry = ExtensionRegistry.newInstance();
registry.add(AnnotationsProto.http);

FileDescriptorSet set = FileDescriptorSet.parseFrom(payload, registry);


//I got only 1 file in the set 
FileDescriptorProto fileDescriptor = set.getFile(0);


//Here I get message type which is used from my grpc service 
(RegisterCustomerRequest). I am sure it is first one.

DescriptorProto requestDescriptor = descriptor.getMessageType(0);


DynamicMessage.Builder messageBuilder = 
DynamicMessage.newBuilder(requestDescriptor);


JsonFormat.parser().merge("{\"customerInfo\":{\"firstName\":\"John\",\"lastName\":\"Doe\"}}",
 messageBuilder);


But parsing the message throw an error: 
com.google.protobuf.InvalidProtocolBufferException: Cannot find field: 
customerInfo in message google.protobuf.DescriptorProto



Can some one guide me what I am doing wrong and how can I parse this JSON 
message ? 

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to