https://github.com/harmnot/protobuf-cheatsheet
protocol buffer for dummy gang
https://github.com/harmnot/protobuf-cheatsheet
Last synced: 4 months ago
JSON representation
protocol buffer for dummy gang
- Host: GitHub
- URL: https://github.com/harmnot/protobuf-cheatsheet
- Owner: harmnot
- Created: 2020-04-18T15:10:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-18T15:12:05.000Z (about 6 years ago)
- Last Synced: 2025-04-12T13:15:34.359Z (about 1 year ago)
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Protobuf
#### create request and respond
```protobuf
syntax = "proto3"
// array : ["string", "string"]
message ArrayStr {
repeated string key = 1
}
// { name: "MY_NAME", gender: "MY_GENDER" }
message MyData {
string name = 1
string gender = 2
}
message Company {
string name = 1
string address = 2
}
// object in array : [ { name: "MY_NAME", gender: "MY_GENDER" } ]
message ArrayObject {
repeated MyData format_data = 1
}
// array in object then array in object
// {
// username: "MY_NAME",
// password: "PASSWORD",
// hobbies: ["Swim", "Gym"],
// familes: [ { name: "DADDY_NAME", gender: "MAN" } ]
// other: { key: "VALUE" }
// }
message ListData {
string username = 1
string password = 2
oneof payload {
repeated ArrayStr hobbies = 3
ArrayObject families = 4
ArrayStr other = 5
}
}
// Any
import "google/protobuf/any.proto";
message ErrorStatus {
string message = 1;
repeated google.protobuf.Any details = 2;
}
// Object with spesific value
message Myself {
string name = 1
map data = 2;
}
// ENUM
message Role {
string name = 1
enum SpesificRole {
root = 0
admin = 1
member = 2
}
SpesificRole as = 2
}
// ListValue
message ListObjects {
ListValue information
}
```