🍋
Menu
Developer

Protocol Buffers

Protocol Buffers (Protobuf)

A language-neutral binary serialization format by Google, more compact and faster than JSON or XML.

Detail Teknis

Protocol Buffers is defined by RFC 8259 and ECMA-404. It supports six data types: string, number, object, array, boolean, and null. JSON numbers have no distinction between integer and float — implementations must handle precision carefully (JavaScript's Number.MAX_SAFE_INTEGER is 2^53 - 1). JSON does not support comments, trailing commas, or single quotes, which are common sources of parse errors. JSON5 and JSONC extend the format with these developer-friendly features.

Contoh

```javascript
// Parse JSON with error handling
try {
  const data = JSON.parse(rawString);
  console.log(data.name); // access properties
} catch (e) {
  console.error('Invalid JSON:', e.message);
}

// Serialize with formatting
const pretty = JSON.stringify(obj, null, 2);
```

Format Terkait

Alat Terkait

Istilah Terkait