分类

数组压缩工具

使用 lodash _.compact 从数组中移除假值

## 数组压缩工具 此工具使用 Lodash 的 `_.compact` 方法从数组中移除假值。 **被移除的假值:** - `false` - `null` - `0` - `""` (空字符串) - `undefined` - `NaN` **示例:** ```json 输入: [0, 1, false, 2, "", 3, null, 4, undefined, 5, NaN] 输出: [1, 2, 3, 4, 5] ``` **选项:** - **保留零值**: 在数组中保留零值 - **保留空字符串**: 在数组中保留空字符串

输入要压缩的 JSON 数组

在数组中保留零 (0) 值

在数组中保留空字符串 ("") 值

API 文档

请求端点

POST /zh/api/tools/compact-array

请求参数

参数名 类型 必填 描述
array textarea 输入要压缩的 JSON 数组
preserveZeros checkbox 在数组中保留零 (0) 值
preserveEmptyStrings checkbox 在数组中保留空字符串 ("") 值

响应格式

{
  "result": "Processed text content",
  "error": "Error message (optional)",
  "message": "Notification message (optional)",
  "metadata": {
    "key": "value"
  }
}
文本: 文本

AI MCP 文档

将此工具添加到您的 MCP 服务器配置中:

{
  "mcpServers": {
    "elysiatools-compact-array": {
      "name": "compact-array",
      "description": "使用 lodash _.compact 从数组中移除假值",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=compact-array",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

你可以串联多个工具,比如:`https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`,最多20个。

如果遇见问题,请联系我们:[email protected]