msgpack

MessagePack 专家:介绍 MessagePack 的用途和优势——一种高效的二进制序列化格式,可作为紧凑的替代 JSON。说明它通常能比 JSON 小 30–50%,解析速度快 2–10 倍,支持所有 JSON 类型以及二进制数据、时间戳和自定义扩展,并指出有 50 多种编程语言的库可用,帮助开发者将数据序列化为更小、更快的二进制格式。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "msgpack":https://skillpi.com/zh/skills/deepskill-b4bb9d9445e1e51a6777b2a9f203656b665724cdf690ef747be89e7ef230d7f3。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

MessagePack 专家:介绍 MessagePack 的用途和优势——一种高效的二进制序列化格式,可作为紧凑的替代 JSON。说明它通常能比 JSON 小 30–50%,解析速度快 2–10 倍,支持所有 JSON 类型以及二进制数据、时间戳和自定义扩展,并指出有 50 多种编程语言的库可用,帮助开发者将数据序列化为更小、更快的二进制格式。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: msgpack
description: >-
  You are an expert in MessagePack, the efficient binary serialization
  format. You help developers replace JSON with a compact binary format that's
  30-50% smaller and 2-10x faster to parse — supporting all JSON types plus
  binary data, timestamps, and custom extensions, with libraries available for
  50+ programming languages.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Developer Tools
  tags:
    - serialization
    - binary
    - json-alternative
    - performance
    - compact
    - cross-language

MessagePack — Efficient Binary Serialization

You are an expert in MessagePack, the efficient binary serialization format. You help developers replace JSON with a compact binary format that's 30-50% smaller and 2-10x faster to parse — supporting all JSON types plus binary data, timestamps, and custom extensions, with libraries available for 50+ programming languages.

Core Capabilities

Node.js Usage

import { encode, decode, Encoder, Decoder, ExtensionCodec } from "@msgpack/msgpack";

// Basic encode/decode
const data = {
  name: "Alice",
  age: 30,
  scores: [95, 87, 92],
  active: true,
  metadata: { role: "admin", lastLogin: new Date() },
};

const packed = encode(data);              // Uint8Array (binary)
console.log(packed.length);               // ~65 bytes vs ~120 bytes JSON

const unpacked = decode(packed);          // Original object

// Custom extension for Date
const extensionCodec = new ExtensionCodec();
extensionCodec.register({
  type: 0,                                // Extension type ID (0-127)
  encode: (input: unknown) => {
    if (input instanceof Date) {
      return encode(input.getTime());
    }
    return null;
  },
  decode: (data: Uint8Array) => {
    return new Date(decode(data) as number);
  },
});

const encoder = new Encoder({ extensionCodec });
const decoder = new Decoder({ extensionCodec });

// Streaming decode for large data
import { decodeMultiStream } from "@msgpack/msgpack";
for await (const item of decodeMultiStream(readableStream)) {
  processItem(item);
}

// WebSocket with MessagePack
ws.binaryType = "arraybuffer";
ws.onmessage = (event) => {
  const data = decode(new Uint8Array(event.data));
  handleMessage(data);
};
ws.send(encode({ type: "subscribe", channel: "metrics" }));

Comparison

const testData = { users: Array.from({ length: 1000 }, (_, i) => ({
  id: i, name: `User ${i}`, email: `user${i}@example.com`, score: Math.random() * 100,
}))};

// JSON: 89,234 bytes, encode 2.1ms, decode 3.4ms
// MessagePack: 52,847 bytes (41% smaller), encode 0.8ms, decode 1.2ms

Installation

npm install @msgpack/msgpack              # JavaScript/TypeScript
pip install msgpack                       # Python
go get github.com/vmihailenco/msgpack/v5  # Go

Best Practices

  1. Replace JSON for internal APIs — Use MessagePack between microservices; keep JSON for public APIs (human-readable)
  2. WebSocket payloads — Use MessagePack for real-time binary data over WebSocket; smaller frames, faster parsing
  3. Cache storage — Store MessagePack in Redis/Memcached; 30-50% less memory than JSON strings
  4. Extension types — Register custom types (Date, BigInt, Decimal) with extension codec; type-safe round-trip
  5. Streaming decode — Use decodeMultiStream for large datasets; process items as they arrive
  6. Content-Type — Use application/x-msgpack or application/msgpack header for HTTP APIs
  7. Schema evolution — Like JSON, MessagePack is schema-less; add/remove fields freely
  8. Fallback to JSON — Support both formats via Accept header; MessagePack for performance, JSON for debugging

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 MessagePack 二进制序列化的全面指导,包括多语言支持与性能优势
  • 涵盖实际开发场景如微服务通信、WebSocket 数据传输、缓存存储等
  • 包含可运行的代码示例和性能对比数据,实用性强
触发精准95/100

亮点

  • description 在 frontmatter 和正文中均完整且一致
  • 清晰定义了 MessagePack 的核心能力与适用场景,触发边界明确
结构规范90/100

亮点

  • 文档结构清晰,分章节组织内容,逻辑流畅
  • 包含端到端代码示例、安装命令和最佳实践清单
  • frontmatter 完整,符合规范
执行可靠88/100

亮点

  • 工具来源明确(官方 npm/pip/go 包),参数正确
  • 代码示例覆盖基本用法、自定义扩展、流式处理等关键场景
  • 无不可逆操作,无需额外确认机制
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 96, 97 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。