I am trying to serialize an object into a byte array using protocol buffers at runtime. To achieve this I need to parse a string containing the .proto file content(created by mapping java class to proto) and compile it using protoc to generate a message and serialize it.
Is this approach doable? and if so are there any references that I can follow to implement this?
My main requirement is to serialize an object into a byte array using protocol buffers without generating a .proto file. The main method would look something like this.
Student s1 = new Student('name', 'id');
proto pr = protoFromClass(Student);
byte[] serializedPr = pr.serialize(s1);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…