syntax = \"proto3\";\r\npackage main;\r\nmessage DataItem {\r\n int64 oddA = 1;\r\n int64 evenA = 2;\r\n int32 oddB = 3;\r\n int32 evenB = 4;\r\n float small = 5;\r\n float big = 6;\r\n string short = 7;\r\n string long = 8;\r\n}<\/pre>\n\u8be5 IDL \u4f7f\u7528\u5f53\u524d\u7684 proto3 \u800c\u4e0d\u662f\u8f83\u65e9\u7684 proto2 \u8bed\u6cd5\u3002\u8f6f\u4ef6\u5305\u540d\u79f0\uff08\u5728\u672c\u4f8b\u4e2d\u4e3a main\uff09\u662f\u53ef\u9009\u7684\uff0c\u4f46\u662f\u60ef\u4f8b\u4f7f\u7528\u5b83\u4ee5\u907f\u514d\u540d\u79f0\u51b2\u7a81\u3002\u8fd9\u4e2a\u7ed3\u6784\u5316\u7684\u6d88\u606f\u5305\u542b\u516b\u4e2a\u5b57\u6bb5\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u90fd\u6709\u4e00\u4e2a Protobuf \u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982\uff0cint64\u3001string\uff09\u3001\u540d\u79f0\uff08\u4f8b\u5982\uff0coddA\u3001short\uff09\u548c\u4e00\u4e2a\u7b49\u53f7 = \u4e4b\u540e\u7684\u6570\u5b57\u6807\u7b7e\uff08\u5373\u952e\uff09\u3002\u6807\u7b7e\uff08\u5728\u6b64\u793a\u4f8b\u4e2d\u4e3a 1 \u5230 8\uff09\u662f\u552f\u4e00\u7684\u6574\u6570\u6807\u8bc6\u7b26\uff0c\u7528\u4e8e\u786e\u5b9a\u5b57\u6bb5\u5e8f\u5217\u5316\u7684\u987a\u5e8f\u3002<\/p>\n
Protobuf \u6d88\u606f\u53ef\u4ee5\u5d4c\u5957\u5230\u4efb\u610f\u7ea7\u522b\uff0c\u800c\u4e00\u4e2a\u6d88\u606f\u53ef\u4ee5\u662f\u53e6\u5916\u4e00\u4e2a\u6d88\u606f\u7684\u5b57\u6bb5\u7c7b\u578b\u3002\u8fd9\u662f\u4e00\u4e2a\u4f7f\u7528 DataItem \u6d88\u606f\u4f5c\u4e3a\u5b57\u6bb5\u7c7b\u578b\u7684\u793a\u4f8b\uff1a<\/p>\n
message DataItems {\r\n repeated DataItem item = 1;\r\n}<\/pre>\n\u5355\u4e2a DataItems \u6d88\u606f\u7531\u91cd\u590d\u7684\uff08\u96f6\u4e2a\u6216\u591a\u4e2a\uff09DataItem \u6d88\u606f\u7ec4\u6210\u3002<\/p>\n
\u4e3a\u4e86\u6e05\u6670\u8d77\u89c1\uff0cProtobuf \u8fd8\u652f\u6301\u679a\u4e3e\u7c7b\u578b\uff1a<\/p>\n
enum PartnershipStatus {\r\n reserved \"FREE\", \"CONSTRAINED\", \"OTHER\";\r\n}<\/pre>\nreserved \u9650\u5b9a\u7b26\u786e\u4fdd\u7528\u4e8e\u5b9e\u73b0\u8fd9\u4e09\u4e2a\u7b26\u53f7\u540d\u7684\u6570\u503c\u4e0d\u80fd\u91cd\u590d\u4f7f\u7528\u3002<\/p>\n
\u4e3a\u4e86\u751f\u6210\u4e00\u4e2a\u6216\u591a\u4e2a\u58f0\u660e Protobuf \u6d88\u606f\u7ed3\u6784\u7684\u7279\u5b9a\u4e8e\u8bed\u8a00\u7684\u7248\u672c\uff0c\u5305\u542b\u8fd9\u4e9b\u7ed3\u6784\u7684 IDL \u6587\u4ef6\u88ab\u4f20\u9012\u5230protoc \u7f16\u8bd1\u5668\uff08\u53ef\u5728 Protobuf GitHub \u5b58\u50a8\u5e93\u4e2d\u627e\u5230\uff09\u3002\u5bf9\u4e8e Go \u4ee3\u7801\uff0c\u53ef\u4ee5\u4ee5\u901a\u5e38\u7684\u65b9\u5f0f\u5b89\u88c5\u652f\u6301\u7684 Protobuf \u5e93\uff08\u8fd9\u91cc\u4ee5 \uff05 \u4f5c\u4e3a\u547d\u4ee4\u884c\u63d0\u793a\u7b26\uff09\uff1a<\/p>\n
% go get github.com\/golang\/protobuf\/proto<\/pre>\n\u5c06 Protobuf IDL \u6587\u4ef6 dataitem.proto \u7f16\u8bd1\u4e3a Go \u6e90\u4ee3\u7801\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n
% protoc --go_out=. dataitem.proto<\/pre>\n\u6807\u5fd7 --go_out \u6307\u793a\u7f16\u8bd1\u5668\u751f\u6210 Go \u6e90\u4ee3\u7801\u3002\u5176\u4ed6\u8bed\u8a00\u4e5f\u6709\u7c7b\u4f3c\u7684\u6807\u5fd7\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a\u540d\u4e3a dataitem.pb.go \u7684\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u8db3\u591f\u5c0f\uff0c\u53ef\u4ee5\u5c06\u5176\u57fa\u672c\u5185\u5bb9\u590d\u5236\u5230 Go \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u4ee5\u4e0b\u662f\u751f\u6210\u7684\u4ee3\u7801\u7684\u4e3b\u8981\u90e8\u5206\uff1a<\/p>\n
var _ = proto.Marshal\r\ntype DataItem struct {\r\n OddA int64 `protobuf:\"varint,1,opt,name=oddA\" json:\"oddA,omitempty\"`\r\n EvenA int64 `protobuf:\"varint,2,opt,name=evenA\" json:\"evenA,omitempty\"`\r\n OddB int32 `protobuf:\"varint,3,opt,name=oddB\" json:\"oddB,omitempty\"`\r\n EvenB int32 `protobuf:\"varint,4,opt,name=evenB\" json:\"evenB,omitempty\"`\r\n Small float32 `protobuf:\"fixed32,5,opt,name=small\" json:\"small,omitempty\"`\r\n Big float32 `protobuf:\"fixed32,6,opt,name=big\" json:\"big,omitempty\"`\r\n Short string `protobuf:\"bytes,7,opt,name=short\" json:\"short,omitempty\"`\r\n Long string `protobuf:\"bytes,8,opt,name=long\" json:\"long,omitempty\"`\r\n}\r\nfunc (m *DataItem) Reset() { *m = DataItem{} }\r\nfunc (m *DataItem) String() string { return proto.CompactTextString(m) }\r\nfunc (*DataItem) ProtoMessage() {}\r\nfunc init() {}\r\n<\/pre>\n\u7f16\u8bd1\u5668\u751f\u6210\u7684\u4ee3\u7801\u5177\u6709 Go \u7ed3\u6784 DataItem\uff0c\u8be5\u7ed3\u6784\u5bfc\u51fa Go \u5b57\u6bb5\uff08\u540d\u79f0\u73b0\u5df2\u5927\u5199\u5f00\u5934\uff09\uff0c\u8be5\u5b57\u6bb5\u4e0e Protobuf IDL \u4e2d\u58f0\u660e\u7684\u540d\u79f0\u5339\u914d\u3002\u8be5\u7ed3\u6784\u5b57\u6bb5\u5177\u6709\u6807\u51c6\u7684 Go \u6570\u636e\u7c7b\u578b\uff1aint32\u3001int64\u3001float32 \u548c string\u3002\u5728\u6bcf\u4e2a\u5b57\u6bb5\u884c\u7684\u672b\u5c3e\uff0c\u662f\u63cf\u8ff0 Protobuf \u7c7b\u578b\u7684\u5b57\u7b26\u4e32\uff0c\u63d0\u4f9b Protobuf IDL \u6587\u6863\u4e2d\u7684\u6570\u5b57\u6807\u7b7e\u53ca\u6709\u5173 JSON \u4fe1\u606f\u7684\u5143\u6570\u636e\uff0c\u8fd9\u5c06\u5728\u540e\u9762\u8ba8\u8bba\u3002<\/p>\n
\u6b64\u5916\u4e5f\u6709\u51fd\u6570\uff1b\u6700\u91cd\u8981\u7684\u662f Proto.Marshal\uff0c\u7528\u4e8e\u5c06 DataItem \u7ed3\u6784\u7684\u5b9e\u4f8b\u5e8f\u5217\u5316\u4e3a Protobuf \u683c\u5f0f\u3002\u8f85\u52a9\u51fd\u6570\u5305\u62ec\uff1a\u6e05\u9664 DataItem \u7ed3\u6784\u7684 Reset\uff0c\u751f\u6210 DataItem \u7684\u5355\u884c\u5b57\u7b26\u4e32\u8868\u793a\u7684 String\u3002<\/p>\n
\u63cf\u8ff0 Protobuf \u7f16\u7801\u7684\u5143\u6570\u636e\u5e94\u5728\u66f4\u8be6\u7ec6\u5730\u5206\u6790 Go \u7a0b\u5e8f\u4e4b\u524d\u8fdb\u884c\u4ed4\u7ec6\u7814\u7a76\u3002<\/p>\n
Protobuf \u7f16\u7801<\/strong><\/div>\nProtobuf \u6d88\u606f\u7684\u7ed3\u6784\u4e3a\u952e\/\u503c\u5bf9\u7684\u96c6\u5408\uff0c\u5176\u4e2d\u6570\u5b57\u6807\u7b7e\u4e3a\u952e\uff0c\u76f8\u5e94\u7684\u5b57\u6bb5\u4e3a\u503c\u3002\u5b57\u6bb5\u540d\u79f0\uff08\u4f8b\u5982\uff0coddA \u548c small\uff09\u662f\u4f9b\u4eba\u7c7b\u9605\u8bfb\u7684\uff0c\u4f46\u662f protoc \u7f16\u8bd1\u5668\u7684\u786e\u4f7f\u7528\u4e86\u5b57\u6bb5\u540d\u79f0\u6765\u751f\u6210\u7279\u5b9a\u4e8e\u8bed\u8a00\u7684\u5bf9\u5e94\u540d\u79f0\u3002\u4f8b\u5982\uff0cProtobuf IDL \u4e2d\u7684 oddA \u548c small \u540d\u79f0\u5728 Go \u7ed3\u6784\u4e2d\u5206\u522b\u6210\u4e3a\u5b57\u6bb5 OddA \u548c Small\u3002<\/p>\n
\u952e\u548c\u5b83\u4eec\u7684\u503c\u90fd\u88ab\u7f16\u7801\uff0c\u4f46\u662f\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u533a\u522b\uff1a\u4e00\u4e9b\u6570\u5b57\u503c\u5177\u6709\u56fa\u5b9a\u5927\u5c0f\u7684 32 \u6216 64 \u4f4d\u7684\u7f16\u7801\uff0c\u800c\u5176\u4ed6\u6570\u5b57\uff08\u5305\u62ec\u6d88\u606f\u6807\u7b7e\uff09\u5219\u662f varint \u7f16\u7801\u7684\uff0c\u4f4d\u6570\u53d6\u51b3\u4e8e\u6574\u6570\u7684\u7edd\u5bf9\u503c\u3002\u4f8b\u5982\uff0c\u6574\u6570\u503c 1 \u5230 15 \u9700\u8981 8 \u4f4d varint \u7f16\u7801\uff0c\u800c\u503c 16 \u5230 2047 \u9700\u8981 16 \u4f4d\u3002varint \u7f16\u7801\u5728\u672c\u8d28\u4e0a\u4e0e UTF-8 \u7f16\u7801\u7c7b\u4f3c\uff08\u4f46\u7ec6\u8282\u4e0d\u540c\uff09\uff0c\u5b83\u504f\u7231\u8f83\u5c0f\u7684\u6574\u6570\u503c\u800c\u4e0d\u662f\u8f83\u5927\u7684\u6574\u6570\u503c\u3002\uff08\u6709\u5173\u8be6\u7ec6\u5206\u6790\uff0c\u8bf7\u53c2\u89c1 Protobuf \u7f16\u7801\u6307\u5357\uff09\u7ed3\u679c\u662f\uff0cProtobuf \u6d88\u606f\u5e94\u8be5\u5728\u5b57\u6bb5\u4e2d\u5177\u6709\u8f83\u5c0f\u7684\u6574\u6570\u503c\uff08\u5982\u679c\u53ef\u80fd\uff09\uff0c\u5e76\u4e14\u952e\u6570\u5e94\u5c3d\u53ef\u80fd\u5c11\uff0c\u4f46\u6bcf\u4e2a\u5b57\u6bb5\u81f3\u5c11\u5f97\u6709\u4e00\u4e2a\u952e\u3002<\/p>\n
\u4e0b\u8868 1 \u5217\u51fa\u4e86 Protobuf \u7f16\u7801\u7684\u8981\u70b9\uff1a<\/p>\n
\n\n\n\u7f16\u7801<\/th>\n | \u793a\u4f8b\u7c7b\u578b<\/th>\n | \u957f\u5ea6<\/th>\n<\/tr>\n<\/thead>\n |
\n\nvarint<\/code><\/td>\nint32<\/code>\u3001uint32<\/code>\u3001int64<\/code><\/td>\n\u53ef\u53d8\u957f\u5ea6<\/td>\n<\/tr>\n | \nfixed<\/code><\/td>\nfixed32<\/code>\u3001float<\/code>\u3001double<\/code><\/td>\n\u56fa\u5b9a\u7684 32 \u4f4d\u6216 64 \u4f4d\u957f\u5ea6<\/td>\n<\/tr>\n | \n\u5b57\u8282\u5e8f\u5217<\/td>\n | string<\/code>\u3001bytes<\/code><\/td>\n\u5e8f\u5217\u957f\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u8868 1. Protobuf \u6570\u636e\u7c7b\u578b<\/p>\n \u672a\u660e\u786e\u56fa\u5b9a\u957f\u5ea6\u7684\u6574\u6570\u7c7b\u578b\u662f varint \u7f16\u7801\u7684\uff1b\u56e0\u6b64\uff0c\u5728 varint \u7c7b\u578b\u4e2d\uff0c\u4f8b\u5982 uint32\uff08u \u4ee3\u8868\u65e0\u7b26\u53f7\uff09\uff0c\u6570\u5b57 32 \u63cf\u8ff0\u4e86\u6574\u6570\u7684\u8303\u56f4\uff08\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e3a 0 \u5230 232 - 1\uff09\uff0c\u800c\u4e0d\u662f\u5176\u4f4d\u7684\u5927\u5c0f\uff0c\u8be5\u4f4d\u5927\u5c0f\u53d6\u51b3\u4e8e\u503c\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u5bf9\u4e8e\u56fa\u5b9a\u957f\u5ea6\u7c7b\u578b\uff08\u4f8b\u5982 fixed32 \u6216 double\uff09\uff0cProtobuf \u7f16\u7801\u5206\u522b\u9700\u8981 32 \u4f4d\u548c 64 \u4f4d\u3002Protobuf \u4e2d\u7684\u5b57\u7b26\u4e32\u662f\u5b57\u8282\u5e8f\u5217\uff1b\u56e0\u6b64\uff0c\u5b57\u6bb5\u7f16\u7801\u7684\u5927\u5c0f\u5c31\u662f\u5b57\u8282\u5e8f\u5217\u7684\u957f\u5ea6\u3002<\/p>\n \u53e6\u4e00\u4e2a\u9ad8\u6548\u7684\u65b9\u6cd5\u503c\u5f97\u4e00\u63d0\u3002\u56de\u60f3\u4e00\u4e0b\u524d\u9762\u7684\u793a\u4f8b\uff0c\u5176\u4e2d\u7684 DataItems \u6d88\u606f\u7531\u91cd\u590d\u7684 DataItem \u5b9e\u4f8b\u7ec4\u6210\uff1a<\/p>\n message DataItems {\r\n repeated DataItem item = 1;\r\n}<\/pre>\nrepeated \u8868\u793a DataItem \u5b9e\u4f8b\u662f\u6253\u5305\u7684\uff1a\u96c6\u5408\u5177\u6709\u5355\u4e2a\u6807\u7b7e\uff0c\u5728\u8fd9\u91cc\u662f 1\u3002\u56e0\u6b64\uff0c\u5177\u6709\u91cd\u590d\u7684 DataItem \u5b9e\u4f8b\u7684 DataItems \u6d88\u606f\u6bd4\u5177\u6709\u591a\u4e2a\u4f46\u5355\u72ec\u7684 DataItem \u5b57\u6bb5\u3001\u6bcf\u4e2a\u5b57\u6bb5\u90fd\u9700\u8981\u81ea\u5df1\u7684\u6807\u7b7e\u7684\u6d88\u606f\u7684\u6548\u7387\u66f4\u9ad8\u3002<\/p>\n \u4e86\u89e3\u4e86\u8fd9\u4e00\u80cc\u666f\uff0c\u8ba9\u6211\u4eec\u56de\u5230 Go \u7a0b\u5e8f\u3002<\/p>\n dataItem \u7a0b\u5e8f\u7684\u7ec6\u8282<\/strong><\/div>\ndataItem \u7a0b\u5e8f\u521b\u5efa\u4e00\u4e2a DataItem \u5b9e\u4f8b\uff0c\u5e76\u4f7f\u7528\u9002\u5f53\u7c7b\u578b\u7684\u968f\u673a\u751f\u6210\u7684\u503c\u586b\u5145\u5b57\u6bb5\u3002Go \u6709\u4e00\u4e2a rand \u5305\uff0c\u5e26\u6709\u7528\u4e8e\u751f\u6210\u4f2a\u968f\u673a\u6574\u6570\u548c\u6d6e\u70b9\u503c\u7684\u51fd\u6570\uff0c\u800c\u6211\u7684 randString \u51fd\u6570\u53ef\u4ee5\u4ece\u5b57\u7b26\u96c6\u4e2d\u751f\u6210\u6307\u5b9a\u957f\u5ea6\u7684\u4f2a\u968f\u673a\u5b57\u7b26\u4e32\u3002\u8bbe\u8ba1\u76ee\u6807\u662f\u8981\u6709\u4e00\u4e2a\u5177\u6709\u4e0d\u540c\u7c7b\u578b\u548c\u4f4d\u5927\u5c0f\u7684\u5b57\u6bb5\u503c\u7684 DataItem \u5b9e\u4f8b\u3002\u4f8b\u5982\uff0cOddA \u548c EvenA \u503c\u5206\u522b\u662f 64 \u4f4d\u975e\u8d1f\u6574\u6570\u503c\u7684\u5947\u6570\u548c\u5076\u6570\uff1b\u4f46\u662f OddB \u548c EvenB \u53d8\u4f53\u7684\u5927\u5c0f\u4e3a 32 \u4f4d\uff0c\u5e76\u5b58\u653e 0 \u5230 2047 \u4e4b\u95f4\u7684\u5c0f\u6574\u6570\u503c\u3002\u968f\u673a\u6d6e\u70b9\u503c\u7684\u5927\u5c0f\u4e3a 32 \u4f4d\uff0c\u5b57\u7b26\u4e32\u4e3a 16\uff08Short\uff09\u548c 32\uff08Long\uff09\u5b57\u7b26\u7684\u957f\u5ea6\u3002\u8fd9\u662f\u7528\u968f\u673a\u503c\u586b\u5145 DataItem \u7ed3\u6784\u7684\u4ee3\u7801\u6bb5\uff1a<\/p>\n \/\/ \u53ef\u53d8\u957f\u5ea6\u6574\u6570\r\nn1 := rand.Int63() \/\/ \u5927\u6574\u6570\r\nif (n1 & 1) == 0 { n1++ } \/\/ \u786e\u4fdd\u5176\u662f\u5947\u6570\r\n...\r\nn3 := rand.Int31() % UpperBound \/\/ \u5c0f\u6574\u6570\r\nif (n3 & 1) == 0 { n3++ } \/\/ \u786e\u4fdd\u5176\u662f\u5947\u6570\r\n\/\/ \u56fa\u5b9a\u957f\u5ea6\u6d6e\u70b9\u6570\r\n...\r\nt1 := rand.Float32()\r\nt2 := rand.Float32()\r\n...\r\n\/\/ \u5b57\u7b26\u4e32\r\nstr1 := randString(StrShort)\r\nstr2 := randString(StrLong)\r\n\/\/ \u6d88\u606f\r\ndataItem := &DataItem {\r\n OddA: n1,\r\n EvenA: n2,\r\n OddB: n3,\r\n EvenB: n4,\r\n Big: f1,\r\n Small: f2,\r\n Short: str1,\r\n Long: str2,\r\n}<\/pre>\n\u521b\u5efa\u5e76\u586b\u5145\u503c\u540e\uff0cDataItem \u5b9e\u4f8b\u5c06\u4ee5 XML\u3001JSON \u548c Protobuf \u8fdb\u884c\u7f16\u7801\uff0c\u6bcf\u79cd\u7f16\u7801\u5747\u5199\u5165\u672c\u5730\u6587\u4ef6\uff1a<\/p>\n func encodeAndserialize(dataItem *DataItem) {\r\n bytes, _ := xml.MarshalIndent(dataItem, \"\", \" \") \/\/ Xml to dataitem.xml\r\n ioutil.WriteFile(XmlFile, bytes, 0644) \/\/ 0644 is file access permissions\r\n bytes, _ = json.MarshalIndent(dataItem, \"\", \" \") \/\/ Json to dataitem.json\r\n ioutil.WriteFile(JsonFile, bytes, 0644)\r\n bytes, _ = proto.Marshal(dataItem) \/\/ Protobuf to dataitem.pbuf\r\n ioutil.WriteFile(PbufFile, bytes, 0644)\r\n}<\/pre>\n\u8fd9\u4e09\u4e2a\u5e8f\u5217\u5316\u51fd\u6570\u4f7f\u7528\u672f\u8bed marshal\uff0c\u5b83\u4e0e serialize \u610f\u601d\u5927\u81f4\u76f8\u540c\u3002\u5982\u4ee3\u7801\u6240\u793a\uff0c\u4e09\u4e2a Marshal \u51fd\u6570\u5747\u8fd4\u56de\u4e00\u4e2a\u5b57\u8282\u6570\u7ec4\uff0c\u7136\u540e\u5c06\u5176\u5199\u5165\u6587\u4ef6\u3002\uff08\u4e3a\u7b80\u5355\u8d77\u89c1\uff0c\u5ffd\u7565\u53ef\u80fd\u7684\u9519\u8bef\u5904\u7406\u3002\uff09\u5728\u793a\u4f8b\u8fd0\u884c\u4e2d\uff0c\u6587\u4ef6\u5927\u5c0f\u4e3a\uff1a<\/p>\n dataitem.xml: 262 bytes\r\ndataitem.json: 212 bytes\r\ndataitem.pbuf: 88 bytes<\/pre>\nProtobuf \u7f16\u7801\u660e\u663e\u5c0f\u4e8e\u5176\u4ed6\u4e24\u4e2a\u7f16\u7801\u65b9\u6848\u3002\u901a\u8fc7\u6d88\u9664\u7f29\u8fdb\u5b57\u7b26\uff08\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e3a\u7a7a\u767d\u548c\u6362\u884c\u7b26\uff09\uff0c\u53ef\u4ee5\u7a0d\u5fae\u51cf\u5c0f XML \u548c JSON \u5e8f\u5217\u5316\u7684\u5927\u5c0f\u3002<\/p>\n \u4ee5\u4e0b\u662f dataitem.json \u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u6700\u7ec8\u662f\u7531 json.MarshalIndent \u8c03\u7528\u4ea7\u751f\u7684\uff0c\u5e76\u6dfb\u52a0\u4e86\u4ee5 ## \u5f00\u5934\u7684\u6ce8\u91ca\uff1a<\/p>\n {\r\n \"oddA\": 4744002665212642479, ## 64-bit >= 0\r\n \"evenA\": 2395006495604861128, ## ditto\r\n \"oddB\": 57, ## 32-bit >= 0 but < 2048\r\n \"evenB\": 468, ## ditto\r\n \"small\": 0.7562016, ## 32-bit floating-point\r\n \"big\": 0.85202795, ## ditto\r\n \"short\": \"ClH1oDaTtoX$HBN5\", ## 16 random chars\r\n \"long\": \"xId0rD3Cri%3Wt%^QjcFLJgyXBu9^DZI\" ## 32 random chars\r\n}<\/pre>\n\u5c3d\u7ba1\u8fd9\u4e9b\u5e8f\u5217\u5316\u7684\u6570\u636e\u5199\u5165\u5230\u672c\u5730\u6587\u4ef6\u4e2d\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u5c06\u6570\u636e\u5199\u5165\u7f51\u7edc\u8fde\u63a5\u7684\u8f93\u51fa\u6d41\u3002<\/p>\n \u6d4b\u8bd5\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/strong><\/div>\nGo \u7a0b\u5e8f\u63a5\u4e0b\u6765\u901a\u8fc7\u5c06\u5148\u524d\u5199\u5165 dataitem.pbuf \u6587\u4ef6\u7684\u5b57\u8282\u53cd\u5e8f\u5217\u5316\u4e3a DataItem \u5b9e\u4f8b\u6765\u8fd0\u884c\u57fa\u672c\u6d4b\u8bd5\u3002\u8fd9\u662f\u4ee3\u7801\u6bb5\uff0c\u5176\u4e2d\u53bb\u9664\u4e86\u9519\u8bef\u68c0\u67e5\u90e8\u5206\uff1a<\/p>\n filebytes, err := ioutil.ReadFile(PbufFile) \/\/ get the bytes from the file\r\n...\r\ntestItem.Reset() \/\/ clear the DataItem structure\r\nerr = proto.Unmarshal(filebytes, testItem) \/\/ deserialize into a DataItem instance<\/pre>\n\u7528\u4e8e Protbuf \u53cd\u5e8f\u5217\u5316\u7684 proto.Unmarshal \u51fd\u6570\u4e0e proto.Marshal \u51fd\u6570\u76f8\u53cd\u3002\u539f\u59cb\u7684 DataItem \u548c\u53cd\u5e8f\u5217\u5316\u7684\u526f\u672c\u5c06\u88ab\u6253\u5370\u51fa\u6765\u4ee5\u786e\u8ba4\u5b8c\u5168\u5339\u914d\uff1a<\/p>\n Original:\r\n2041519981506242154 3041486079683013705 1192 1879\r\n0.572123 0.326855\r\nboPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk&\r\nDeserialized:\r\n2041519981506242154 3041486079683013705 1192 1879\r\n0.572123 0.326855\r\nboPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk&<\/pre>\n\u4e00\u4e2a Java Protobuf \u5ba2\u6237\u7aef<\/strong><\/div>\n\u7528 Java \u5199\u7684\u793a\u4f8b\u662f\u4e3a\u4e86\u786e\u8ba4 Protobuf \u7684\u8bed\u8a00\u4e2d\u7acb\u6027\u3002\u539f\u59cb IDL \u6587\u4ef6\u53ef\u7528\u4e8e\u751f\u6210 Java \u652f\u6301\u4ee3\u7801\uff0c\u5176\u4e2d\u6d89\u53ca\u5d4c\u5957\u7c7b\u3002\u4f46\u662f\uff0c\u4e3a\u4e86\u6291\u5236\u8b66\u544a\u4fe1\u606f\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u8865\u5145\u3002\u8fd9\u662f\u4fee\u8ba2\u7248\uff0c\u5b83\u6307\u5b9a\u4e86\u4e00\u4e2a DataMsg \u4f5c\u4e3a\u5916\u90e8\u7c7b\u7684\u540d\u79f0\uff0c\u5185\u90e8\u7c7b\u5728\u8be5 Protobuf \u6d88\u606f\u540e\u9762\u81ea\u52a8\u547d\u540d\u4e3a DataItem\uff1a<\/p>\n syntax = \"proto3\";\r\npackage main;\r\noption java_outer_classname = \"DataMsg\";\r\nmessage DataItem {\r\n...<\/pre>\n\u8fdb\u884c\u6b64\u66f4\u6539\u540e\uff0cprotoc \u7f16\u8bd1\u4e0e\u4ee5\u524d\u76f8\u540c\uff0c\u53ea\u662f\u6240\u671f\u671b\u7684\u8f93\u51fa\u73b0\u5728\u662f Java \u800c\u4e0d\u662f Go\uff1a<\/p>\n % protoc --java_out=. dataitem.proto<\/pre>\n\u751f\u6210\u7684\u6e90\u6587\u4ef6\uff08\u5728\u540d\u4e3a main \u7684\u5b50\u76ee\u5f55\u4e2d\uff09\u4e3a DataMsg.java\uff0c\u957f\u5ea6\u7ea6\u4e3a 1,120 \u884c\uff1aJava \u5e76\u4e0d\u7b80\u6d01\u3002\u7f16\u8bd1\u7136\u540e\u8fd0\u884c Java \u4ee3\u7801\u9700\u8981\u5177\u6709 Protobuf \u5e93\u652f\u6301\u7684 JAR \u6587\u4ef6\u3002\u8be5\u6587\u4ef6\u4f4d\u4e8e Maven \u5b58\u50a8\u5e93\u4e2d\u3002<\/p>\n \u653e\u7f6e\u597d\u8fd9\u4e9b\u7247\u6bb5\u540e\uff0c\u6211\u7684\u6d4b\u8bd5\u4ee3\u7801\u76f8\u5bf9\u8f83\u77ed\uff08\u5e76\u4e14\u5728 ZIP \u6587\u4ef6\u4e2d\u4ee5 Main.java \u5f62\u5f0f\u63d0\u4f9b\uff09\uff1a<\/p>\n package main;\r\nimport java.io.FileInputStream;\r\npublic class Main {\r\n public static void main(String[] args) {\r\n String path = \"dataitem.pbuf\"; \/\/ from the Go program's serialization\r\n try {\r\n DataMsg.DataItem deserial =\r\n DataMsg.DataItem.newBuilder().mergeFrom(new FileInputStream(path)).build();\r\n System.out.println(deserial.getOddA()); \/\/ 64-bit odd\r\n System.out.println(deserial.getLong()); \/\/ 32-character string\r\n }\r\n catch(Exception e) { System.err.println(e); }\r\n }\r\n}<\/pre>\n\u5f53\u7136\uff0c\u751f\u4ea7\u7ea7\u7684\u6d4b\u8bd5\u5c06\u66f4\u52a0\u5f7b\u5e95\uff0c\u4f46\u662f\u5373\u4f7f\u662f\u8be5\u521d\u6b65\u6d4b\u8bd5\u4e5f\u53ef\u4ee5\u8bc1\u660e Protobuf \u7684\u8bed\u8a00\u4e2d\u7acb\u6027\uff1adataitem.pbuf \u6587\u4ef6\u662f Go \u7a0b\u5e8f\u5bf9 Go \u8bed\u8a00\u7248\u7684 DataItem \u8fdb\u884c\u5e8f\u5217\u5316\u7684\u7ed3\u679c\uff0c\u5e76\u4e14\u8be5\u6587\u4ef6\u4e2d\u7684\u5b57\u8282\u88ab\u53cd\u5e8f\u5217\u5316\u4ee5\u4ea7\u751f\u4e00\u4e2a Java \u8bed\u8a00\u7684 DataItem \u5b9e\u4f8b\u3002Java \u6d4b\u8bd5\u7684\u8f93\u51fa\u4e0e Go \u6d4b\u8bd5\u7684\u8f93\u51fa\u76f8\u540c\u3002<\/p>\n \u7528 numPairs \u7a0b\u5e8f\u6765\u7ed3\u675f<\/strong><\/div>\n\u8ba9\u6211\u4eec\u4ee5\u4e00\u4e2a\u793a\u4f8b\u4f5c\u4e3a\u7ed3\u5c3e\uff0c\u6765\u7a81\u51fa Protobuf \u6548\u7387\uff0c\u4f46\u53c8\u5f3a\u8c03\u5728\u4efb\u4f55\u7f16\u7801\u6280\u672f\u4e2d\u90fd\u4f1a\u6d89\u53ca\u5230\u7684\u6210\u672c\u3002\u8003\u8651\u4ee5\u4e0b Protobuf IDL \u6587\u4ef6\uff1a<\/p>\n syntax = \"proto3\";\r\npackage main;\r\nmessage NumPairs {\r\n repeated NumPair pair = 1;\r\n}\r\nmessage NumPair {\r\n int32 odd = 1;\r\n int32 even = 2;\r\n}<\/pre>\nNumPair \u6d88\u606f\u7531\u4e24\u4e2a int32 \u503c\u4ee5\u53ca\u6bcf\u4e2a\u5b57\u6bb5\u7684\u6574\u6570\u6807\u7b7e\u7ec4\u6210\u3002NumPairs \u6d88\u606f\u662f\u5d4c\u5165\u7684 NumPair \u6d88\u606f\u7684\u5e8f\u5217\u3002<\/p>\n Go \u8bed\u8a00\u7684 numPairs \u7a0b\u5e8f\uff08\u5982\u4e0b\uff09\u521b\u5efa\u4e86 200 \u4e07\u4e2a NumPair \u5b9e\u4f8b\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u90fd\u9644\u52a0\u5230 NumPairs \u6d88\u606f\u4e2d\u3002\u8be5\u6d88\u606f\u53ef\u4ee5\u6309\u5e38\u89c4\u65b9\u5f0f\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002<\/p>\n \u793a\u4f8b 2\u3001numPairs \u7a0b\u5e8f<\/strong><\/span><\/div>\npackage main\r\nimport (\r\n \"math\/rand\"\r\n \"time\"\r\n \"encoding\/xml\"\r\n \"encoding\/json\"\r\n \"io\/ioutil\"\r\n \"github.com\/golang\/protobuf\/proto\"\r\n)\r\n\/\/ protoc-generated code: start\r\nvar _ = proto.Marshal\r\ntype NumPairs struct {\r\n Pair []*NumPair `protobuf:\"bytes,1,rep,name=pair\" json:\"pair,omitempty\"`\r\n}\r\nfunc (m *NumPairs) Reset() { *m = NumPairs{} }\r\nfunc (m *NumPairs) String() string { return proto.CompactTextString(m) }\r\nfunc (*NumPairs) ProtoMessage() {}\r\nfunc (m *NumPairs) GetPair() []*NumPair {\r\n if m != nil { return m.Pair }\r\n return nil\r\n}\r\ntype NumPair struct {\r\n Odd int32 `protobuf:\"varint,1,opt,name=odd\" json:\"odd,omitempty\"`\r\n Even int32 `protobuf:\"varint,2,opt,name=even\" json:\"even,omitempty\"`\r\n}\r\nfunc (m *NumPair) Reset() { *m = NumPair{} }\r\nfunc (m *NumPair) String() string { return proto.CompactTextString(m) }\r\nfunc (*NumPair) ProtoMessage() {}\r\nfunc init() {}\r\n\/\/ protoc-generated code: finish\r\nvar numPairsStruct NumPairs\r\nvar numPairs = &numPairsStruct\r\nfunc encodeAndserialize() {\r\n \/\/ XML encoding\r\n filename := \".\/pairs.xml\"\r\n bytes, _ := xml.MarshalIndent(numPairs, \"\", \" \")\r\n ioutil.WriteFile(filename, bytes, 0644)\r\n \/\/ JSON encoding\r\n filename = \".\/pairs.json\"\r\n bytes, _ = json.MarshalIndent(numPairs, \"\", \" \")\r\n ioutil.WriteFile(filename, bytes, 0644)\r\n \/\/ ProtoBuf encoding\r\n filename = \".\/pairs.pbuf\"\r\n bytes, _ = proto.Marshal(numPairs)\r\n ioutil.WriteFile(filename, bytes, 0644)\r\n}\r\nconst HowMany = 200 * 100 * 100 \/\/ two million\r\nfunc main() {\r\n rand.Seed(time.Now().UnixNano())\r\n \/\/ uncomment the modulus operations to get the more efficient version\r\n for i := 0; i < HowMany; i++ {\r\n n1 := rand.Int31() \/\/ % 2047\r\n if (n1 & 1) == 0 { n1++ } \/\/ ensure it's odd\r\n n2 := rand.Int31() \/\/ % 2047\r\n if (n2 & 1) == 1 { n2++ } \/\/ ensure it's even\r\n next := &NumPair {\r\n Odd: n1,\r\n Even: n2,\r\n }\r\n numPairs.Pair = append(numPairs.Pair, next)\r\n }\r\n encodeAndserialize()<\/pre>\n\u6bcf\u4e2a NumPair \u4e2d\u968f\u673a\u751f\u6210\u7684\u5947\u6570\u548c\u5076\u6570\u503c\u7684\u8303\u56f4\u5728 0 \u5230 20 \u4ebf\u4e4b\u95f4\u53d8\u5316\u3002\u5c31\u539f\u59cb\u6570\u636e\uff08\u800c\u975e\u7f16\u7801\u6570\u636e\uff09\u800c\u8a00\uff0cGo \u7a0b\u5e8f\u4e2d\u751f\u6210\u7684\u6574\u6570\u603b\u5171\u4e3a 16MB\uff1a\u6bcf\u4e2a NumPair \u4e3a\u4e24\u4e2a\u6574\u6570\uff0c\u603b\u8ba1\u4e3a 400 \u4e07\u4e2a\u6574\u6570\uff0c\u6bcf\u4e2a\u503c\u7684\u5927\u5c0f\u4e3a\u56db\u4e2a\u5b57\u8282\u3002<\/p>\n \u4e3a\u4e86\u8fdb\u884c\u6bd4\u8f83\uff0c\u4e0b\u8868\u5217\u51fa\u4e86 XML\u3001JSON \u548c Protobuf \u7f16\u7801\u7684\u793a\u4f8b NumsPairs \u6d88\u606f\u7684 200 \u4e07\u4e2a NumPair \u5b9e\u4f8b\u3002\u539f\u59cb\u6570\u636e\u4e5f\u5305\u62ec\u5728\u5185\u3002\u7531\u4e8e numPairs \u7a0b\u5e8f\u751f\u6210\u968f\u673a\u503c\uff0c\u56e0\u6b64\u6837\u672c\u8fd0\u884c\u7684\u8f93\u51fa\u6709\u6240\u4e0d\u540c\uff0c\u4f46\u63a5\u8fd1\u8868\u4e2d\u663e\u793a\u7684\u5927\u5c0f\u3002<\/p>\n \n\n\n\u7f16\u7801<\/th>\n | \u6587\u4ef6<\/th>\n | \u5b57\u8282\u5927\u5c0f<\/th>\n | Pbuf\/\u5176\u5b83 \u6bd4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n | \n\n\u65e0<\/td>\n | pairs.raw<\/td>\n | 16MB<\/td>\n | 169%<\/td>\n<\/tr>\n | \nProtobuf<\/td>\n | pairs.pbuf<\/td>\n | 27MB<\/td>\n | \u2014<\/td>\n<\/tr>\n | \nJSON<\/td>\n | pairs.json<\/td>\n | 100MB<\/td>\n | 27%<\/td>\n<\/tr>\n | \nXML<\/td>\n | pairs.xml<\/td>\n | 126MB<\/td>\n | 21%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u8868 2. 16MB \u6574\u6570\u7684\u7f16\u7801\u5f00\u9500<\/p>\n \u4e0d\u51fa\u6240\u6599\uff0cProtobuf \u548c\u4e4b\u540e\u7684 XML \u548c JSON \u5dee\u522b\u660e\u663e\u3002Protobuf \u7f16\u7801\u5927\u7ea6\u662f JSON \u7684\u56db\u5206\u4e4b\u4e00\uff0c\u662f XML \u7684\u4e94\u5206\u4e4b\u4e00\u3002\u4f46\u662f\u539f\u59cb\u6570\u636e\u6e05\u695a\u5730\u8868\u660e Protobuf \u4e5f\u4f1a\u4ea7\u751f\u7f16\u7801\u5f00\u9500\uff1a\u5e8f\u5217\u5316\u7684 Protobuf \u6d88\u606f\u6bd4\u539f\u59cb\u6570\u636e\u5927 11MB\u3002\u5305\u62ec Protobuf \u5728\u5185\u7684\u4efb\u4f55\u7f16\u7801\u90fd\u6d89\u53ca\u7ed3\u6784\u5316\u6570\u636e\uff0c\u8fd9\u4e0d\u53ef\u907f\u514d\u5730\u4f1a\u589e\u52a0\u5b57\u8282\u3002<\/p>\n \u5e8f\u5217\u5316\u7684 200 \u4e07\u4e2a NumPair \u5b9e\u4f8b\u4e2d\u7684\u6bcf\u4e2a\u5b9e\u4f8b\u90fd\u5305\u542b\u56db\u4e2a\u6574\u6570\u503c\uff1aGo \u7ed3\u6784\u4e2d\u7684 Even \u548c Odd \u5b57\u6bb5\u5206\u522b\u4e00\u4e2a\uff0c\u800c Protobuf \u7f16\u7801\u4e2d\u7684\u6bcf\u4e2a\u5b57\u6bb5\u3001\u6bcf\u4e2a\u6807\u7b7e\u4e00\u4e2a\u3002\u5bf9\u4e8e\u539f\u59cb\u6570\u636e\uff08\u800c\u4e0d\u662f\u7f16\u7801\u6570\u636e\uff09\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u5c06\u8fbe\u5230 16 \u4e2a\u5b57\u8282\uff0c\u6837\u672c NumPairs \u6d88\u606f\u4e2d\u6709 200 \u4e07\u4e2a\u5b9e\u4f8b\u3002\u4f46\u662f Protobuf \u6807\u8bb0\uff08\u5982 NumPair \u5b57\u6bb5\u4e2d\u7684 int32 \u503c\uff09\u4f7f\u7528 varint \u7f16\u7801\uff0c\u56e0\u6b64\u5b57\u8282\u957f\u5ea6\u6709\u6240\u4e0d\u540c\u3002\u7279\u522b\u662f\uff0c\u5c0f\u7684\u6574\u6570\u503c\uff08\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5305\u62ec\u6807\u7b7e\u5728\u5185\uff09\u9700\u8981\u4e0d\u5230\u56db\u4e2a\u5b57\u8282\u8fdb\u884c\u7f16\u7801\u3002<\/p>\n \u5982\u679c\u5bf9 numPairs \u7a0b\u5e8f\u8fdb\u884c\u4e86\u4fee\u6539\uff0c\u4ee5\u4f7f\u4e24\u4e2a NumPair \u5b57\u6bb5\u7684\u503c\u5c0f\u4e8e 2048\uff0c\u4e14\u5176\u7f16\u7801\u4e3a\u4e00\u6216\u4e24\u4e2a\u5b57\u8282\uff0c\u5219 Protobuf \u7f16\u7801\u5c06\u4ece 27MB \u4e0b\u964d\u5230 16MB\uff0c\u8fd9\u6b63\u662f\u539f\u59cb\u6570\u636e\u7684\u5927\u5c0f\u3002\u4e0b\u8868\u603b\u7ed3\u4e86\u6837\u672c\u8fd0\u884c\u4e2d\u7684\u65b0\u7f16\u7801\u5927\u5c0f\u3002<\/p>\n \n\n\n\u7f16\u7801<\/th>\n | \u6587\u4ef6<\/th>\n | \u5b57\u8282\u5927\u5c0f<\/th>\n | Pbuf\/\u5176\u5b83 \u6bd4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n | \n\nNone<\/td>\n | pairs.raw<\/td>\n | 16MB<\/td>\n | 100%<\/td>\n<\/tr>\n | \nProtobuf<\/td>\n | pairs.pbuf<\/td>\n | 16MB<\/td>\n | \u2014<\/td>\n<\/tr>\n | \nJSON<\/td>\n | pairs.json<\/td>\n | 77MB<\/td>\n | 21%<\/td>\n<\/tr>\n | \nXML<\/td>\n | pairs.xml<\/td>\n | 103MB<\/td>\n | 15%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u8868 3. \u7f16\u7801 16MB \u7684\u5c0f\u4e8e 2048 \u7684\u6574\u6570<\/p>\n \u603b\u4e4b\uff0c\u4fee\u6539\u540e\u7684 numPairs \u7a0b\u5e8f\u7684\u5b57\u6bb5\u503c\u5c0f\u4e8e 2048\uff0c\u53ef\u51cf\u5c11\u539f\u59cb\u6570\u636e\u4e2d\u6bcf\u4e2a\u56db\u5b57\u8282\u6574\u6570\u503c\u7684\u5927\u5c0f\u3002\u4f46\u662f Protobuf \u7f16\u7801\u4ecd\u7136\u9700\u8981\u6807\u7b7e\uff0c\u8fd9\u4e9b\u6807\u7b7e\u4f1a\u5728 Protobuf \u6d88\u606f\u4e2d\u6dfb\u52a0\u5b57\u8282\u3002Protobuf \u7f16\u7801\u786e\u5b9e\u4f1a\u589e\u52a0\u6d88\u606f\u5927\u5c0f\uff0c\u4f46\u662f\u5982\u679c\u8981\u7f16\u7801\u76f8\u5bf9\u8f83\u5c0f\u7684\u6574\u6570\u503c\uff08\u65e0\u8bba\u662f\u5b57\u6bb5\u8fd8\u662f\u952e\uff09\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7 varint \u56e0\u5b50\u6765\u51cf\u5c11\u6b64\u5f00\u9500\u3002<\/p>\n \u5bf9\u4e8e\u5305\u542b\u6df7\u5408\u7c7b\u578b\u7684\u7ed3\u6784\u5316\u6570\u636e\uff08\u4e14\u6574\u6570\u503c\u76f8\u5bf9\u8f83\u5c0f\uff09\u7684\u4e2d\u7b49\u5927\u5c0f\u7684\u6d88\u606f\uff0cProtobuf \u660e\u663e\u4f18\u4e8e XML \u548c JSON \u7b49\u9009\u9879\u3002\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u53ef\u80fd\u4e0d\u9002\u5408 Protobuf \u7f16\u7801\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u4e2a\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u5171\u4eab\u5927\u91cf\u6587\u672c\u8bb0\u5f55\u6216\u5927\u6574\u6570\u503c\uff0c\u5219\u53ef\u4ee5\u91c7\u7528\u538b\u7f29\u800c\u4e0d\u662f\u7f16\u7801\u6280\u672f\u3002<\/p>\n via: https:\/\/opensource.com\/article\/19\/10\/protobuf-data-interchange<\/p>\n \u4f5c\u8005\uff1aMarty Kalin \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1awxy \u6821\u5bf9\uff1awxy<\/p>\n \u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":" Protocol Buffers\uff08Protobufs\uff09\u50cf XML \u548c JSON \u4e00\u6837\uff0c\u53ef\u4ee5\u8ba9\u7528\u4e0d\u540c\u8bed\u8a00\u7f16\u5199\u5e76\u5728 […]<\/p>\n","protected":false},"author":1920,"featured_media":167772,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-167766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1920"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=167766"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167766\/revisions"}],"predecessor-version":[{"id":168195,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167766\/revisions\/168195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/167772"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=167766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=167766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=167766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} | | | | | | | |