Protobuf로 인코딩

는 해당 표준에 따라 “Protobuf”로 입력을 인코딩합니다.

입력: 구조화된 JSON결과: 이진 바이트

텍스트 입력

실행하면 결과가 표시됩니다

메시지 타입과 필드 이름을 정의하는 .proto 스키마를 입력합니다.

예제

A small field value

입력

{"counter": 1}

Expected answer

Hexadecimal bytes
08 01
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
A 7-bit boundary

입력

{"counter": 127}

Expected answer

Hexadecimal bytes
08 7f
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
The first two-byte value

입력

{"counter": 128}

Expected answer

Hexadecimal bytes
08 80 01
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
The official Protobuf example

입력

{"counter": 150}

Expected answer

Hexadecimal bytes
08 96 01
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
A counter of 300

입력

{"counter": 300}

Expected answer

Hexadecimal bytes
08 ac 02
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
A three-byte boundary

입력

{"counter": 16384}

Expected answer

Hexadecimal bytes
08 80 80 01
스키마(.proto 텍스트)
syntax="proto3"; message Event { int32 counter = 1; }
Protobuf Encode

입력

{
    "Apple": [
        28
    ],
    "Banana": "You",
    "Carrot": [
        "Me"
    ],
    "Date": 43,
    "Elderberry": {
        "Fig": "abc123",
        "Grape": {}
    },
    "Huckleberry": [
        3029774971578
    ],
    "Imbe": 1
}

Expected answer

Hexadecimal bytes
0d 1c 00 00 00 12 03 59 6f 75 1a 02 4d 65 20 2b 2a 0a 0a 06 61 62 63 31 32 33 12 00 31 ba 32 a9 6c c1 02 00 00 38 01
스키마(.proto 텍스트)
message Test { repeated fixed32 Apple = 1; optional string Banana = 2; repeated string Carrot = 3; optional int32 Date = 4; optional subTest Elderberry = 5; repeated fixed64 Huckleberry = 6; optional Options Imbe = 7; } message subTest { optional string Fig = 1; optional subSubTest Grape = 2; } message subSubTest {} enum Options { Option0 = 0; Option1 = 1; Option2 = 2; }
incomplete schema

입력

{
    "Apple": [
        28
    ],
    "Banana": "You",
    "Carrot": [
        "Me"
    ],
    "Date": 43,
    "Elderberry": {
        "Fig": "abc123",
        "Grape": {}
    },
    "Huckleberry": [
        3029774971578
    ],
    "Imbe": 1
}

Expected answer

Hexadecimal bytes
12 03 59 6f 75 20 2b 2a 0a 0a 06 61 62 63 31 32 33 12 00 31 ba 32 a9 6c c1 02 00 00
스키마(.proto 텍스트)
message Test { optional string Banana = 2; optional int32 Date = 4; optional subTest Elderberry = 5; repeated fixed64 Huckleberry = 6; } message subTest { optional string Fig = 1; optional subSubTest Grape = 2; } message subSubTest {} enum Options { Option0 = 0; Option1 = 1; Option2 = 2; }

관련 도구

네트워크

작업 참고 자료

원본 기술 문서 보기 (English)