1. Schema Definition Language (SDL):

    syntax = "proto3";
    
    message Person {
      string name = 1;
      int32 age = 2;
      repeated string emails = 3;
    }
    
  2. Data Types:

  3. Defining Messages:

    message Person {
      string name = 1;
      int32 age = 2;
    }
    
  4. Nested Messages:

    message Address {
      string street = 1;
      string city = 2;
    }
    
    message Person {
      string name = 1;
      int32 age = 2;
      Address address = 3;
    }
    
  5. Enums:

    enum Color {
      RED = 0;
      BLUE = 1;
      GREEN = 2;
    }
    
    message Person {
      string name = 1;
      int32 age = 2;
      Color favorite_color = 3;
    }
    
  6. Repeated Fields:

  7. Code Generation:

  8. Serialization:

    // Assume a Person message object
    Person person = Person.newBuilder()
        .setName("Alice")
        .setAge(25)
        .addEmails("[email protected]")
        .addEmails("[email protected]")
        .build();
    
    // Serialize the message to a byte array
    byte[] serializedData = person.toByteArray();
    
  9. Deserialization:

    // Assume we have the serializedData byte array
    Person person = Person.parseFrom(serializedData);
    System.out.println(person.getName()); // "Alice"
    System.out.println(person.getAge());  // 25
    
  10. Versioning and Compatibility:

  11. Interoperability:

Protobufs offer a compact binary representation, faster serialization/deserialization, and versioning flexibility, making them popular for data interchange between different systems.

More information here:

Understanding Protocol Buffers

Postman