- 依赖
<dependency>
<groupId>io.protostuff</groupId>
<artifactId>protostuff-core</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>io.protostuff</groupId>
<artifactId>protostuff-runtime</artifactId>
<version>1.4.0</version>
</dependency>
- 代码
RuntimeSchema<School> schema = RuntimeSchema.createFrom(School.class);
// 序列化
School sc = new School("哈哈多名受访的第三方","广州天河南二路","13357384990","1098");
byte[] bytes = ProtostuffIOUtil.toByteArray(sc, schema,
LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE));
// 反序列化
// 空对象
School school = schema.newMessage();
// 反序列化
ProtostuffIOUtil.mergeFrom(bytes,school,schema);