Hi all,

If you were ever curious about using protobuf dynamically (no protoc 
compiler) but found that difficult to use, this API may be of interest 

You can create DynamicSchemas on the fly at runtime, then use them as 
factories for regular protobuf DynamicMessages

protobuf-dynamic 0.9 (beta) is now available on Maven Central


// Create dynamic schemaDynamicSchema.Builder schemaBuilder = 
MessageDefinition msgDef = MessageDefinition.newBuilder("Person") // message 
        .addField("required", "int32", "id", 1)     // required int32 id = 1
        .addField("required", "string", "name", 2)  // required string name = 2
        .addField("optional", "string", "email", 3) // optional string email = 3

schemaBuilder.addMessageDefinition(msgDef);DynamicSchema schema = 
// Create dynamic message from schemaDynamicMessage.Builder msgBuilder = 
schema.newMessageBuilder("Person");Descriptor msgDesc = 
msgBuilder.getDescriptorForType();DynamicMessage msg = msgBuilder
        .setField(msgDesc.findFieldByName("id"), 1)
        .setField(msgDesc.findFieldByName("name"), "Alan Turing")
        .setField(msgDesc.findFieldByName("email"), "a...@sis.gov.uk")

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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to