Skip to content

Commit 9604bbe

Browse files
authored
Update README.md
1 parent 83f1e39 commit 9604bbe

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# First Protobuf (`.proto`) Javascript
22

3-
> A quick and practical look at Protobuf.
3+
### A quick and practical look at Protobuf.
44

55
If you know what is **JSON** and how its work, you can see how much **Proto-Buf** is easy.
66

@@ -15,6 +15,35 @@ What you dont know you think its hard but when you start to test and working on,
1515
$ protoc --js_out=import_style=commonjs,binary:. employees.proto
1616
```
1717

18+
### Compare JSON and Protobuf Data size
19+
20+
| Size | Filename | Method |
21+
|------|---------------|----------|
22+
| 123 | employees.json| JSON |
23+
| 48 | employees.bin | Protobuf |
24+
25+
## Output of examples
26+
27+
> [max@workstation gRPC-JS]$ node protobuf.js
28+
```
29+
Ali name is: ALI
30+
Reza name is: REZA
31+
Javad name is: JAVAD
32+
Data: 1001,ALI,50001,1002,REZA,50002,1003,JAVAD,50003
33+
Binary: 10,13,8,233,7,18,3,65,76,73,29,0,81,67,71,10,14,8,234,7,18,4,82,69,90,65,29,0,82,67,71,10,15,8,235,7,18,5,74,65,86,65,68,29,0,83,67,71
34+
Read data from bytes: 1001,ALI,50001,1002,REZA,50002,1003,JAVAD,50003
35+
```
36+
37+
> [max@workstation gRPC-JS]$ node json.js
38+
```
39+
Ali name is: ALI
40+
Reza name is: REZA
41+
Javad name is: REZA
42+
Data: [object Object],[object Object],[object Object]
43+
JSON: [{"id":1001,"name":"ALI","salary":50001},{"id":1002,"name":"REZA","salary":50002},{"id":1002,"name":"REZA","salary":50002}]
44+
Read data from JSON: [object Object],[object Object],[object Object]
45+
```
46+
1847
## Download `protoc`
1948

2049
You need to install `protoc` program on your system, you can download it from https://github.com/protocolbuffers/protobuf/releases depends on your Operation system. whatever your system is Liunx, Windows or OSX.

0 commit comments

Comments
 (0)