Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加由.proto 描述文件动态生成Protobuf操作对象的支持 #4

Closed
Baidu-etech opened this issue Sep 29, 2014 · 3 comments
Closed
Assignees
Milestone

Comments

@Baidu-etech
Copy link
Collaborator

支持直接根据.proto描述文件动态生成protobuf操作对象,这样可以极简化google protobuf的使用,同时针对需要动态根据.proto描述文件进行操作的实现也是非常有用的帮助

@Baidu-etech
Copy link
Collaborator Author

功能已经增加,详见使用说明

@jhunters
Copy link
Owner

该功能目前不支持嵌套对象的方式,只能支持单对象定义的proto描述文件

@jhunters
Copy link
Owner

在1.0.3版本中,已经支持了对嵌套对象的功能支持。
IDLProxyObject object = ProtobufIDLProxy.createSingle(protoCotent);
//if .proto IDL defines multiple messages use as follow
//Map<String, IDLProxyObject> objects = ProtobufIDLProxy.create(protoCotent);
// 动态设置字段值
object.put("message", "hello你好");
//propogation object set
//object.put("sub.field", "hello world");
// protobuf 序列化
byte[] bb = object.encode();

// protobuf 反序列化
IDLProxyObject result = object.decode(bb);
Assert.assertEquals("hello你好", result.get("message"));
//propogation object get
//result.get("sub.field");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants