打乱 JSON 数据

验证 JSON 结构,然后安全地随机排列符合条件的对象,同时保留有效输出。

jhauga
2026年10月10日
0 收藏
658 下载

安装与下载

1 ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install shuffle-json-data

2 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/
工作区 {'/skills/'}

优先级:工作区 › 全局 › 内置

3 提示词安装

将此提示词复制到 Openclaw 即可自动安装。

请帮我使用 Clawhub 安装 skill-shuffle-json-data。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

更倾向于下载?

获取包含原生技能文件的ZIP压缩包。

下载技能 (.zip)

基本信息

名称 打乱 JSON 数据
Slug shuffle-json-data
创建者 jhauga
创建时间 2026-10-10 05:40:16
更新时间 2026-10-10 05:40:16
收藏数 0
使用量 658
浏览量 9

安装指南

  1. ClawHub CLI 从源直接安装技能的最快方式。
    npx clawhub@latest install shuffle-json-data
  2. 手动安装 将技能文件夹复制到以下位置之一
    全局模式
    ~/.openclaw/skills/
    工作区
    /skills/
    优先级:工作区 > 本地 > 内置
  3. 提示词安装 将此提示词复制到 OpenClaw 即可自动安装。
    请帮我使用 Clawhub 安装 shuffle-json-data。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
    更倾向于下载?
    获取包含原生技能文件的ZIP压缩包。
    下载技能 (.zip)

什么是

打乱 JSON 数据是 Openclaw Skills 中的一种工作流,可在不损害数据完整性的前提下重新排列重复的 JSON 对象。它会在打乱前检查输入是否有效且结构一致;如果默认规则无法安全处理数据,则会停止并说明原因。
默认情况下,此技能会在对象级别进行打乱,并要求对象具有相同的属性名称且不包含嵌套对象。使用 Variables 标头或提示级覆盖项来指定集合、必需属性、忽略属性,或是否应处理嵌套结构。

应用场景

为测试、抽样或准备下游工作流的数据随机排列 JSON 集合。
重新排列由统一 JSON 对象组成的列表,同时保留有效的 JSON 语法。
从必需属性检查中排除特定属性,例如
year
category
。
验证输入数据时要求包含选定属性。
仅在明确的配置清楚说明预期行为时,处理包含嵌套对象的 JSON 文件。
在进行任何更改之前,发现文件缺失、JSON 格式错误、属性不一致或不受支持的结构。

工作原理

收集输入: 确认 JSON 文件或兼容的 JSON 结构可用。如果没有,则暂停并请求提供。
检查配置: 应用默认设置,然后纳入通过 Variables 或请求提供的变量。
验证输入: 检查 JSON 语法;默认情况下,还会确认对象具有相同的属性名称且不包含嵌套对象。
停止或继续: 报告不一致之处且不修改数据,除非明确的覆盖项定义了安全的处理方式。
打乱: 随机排列指定的集合,或使用默认的对象级行为。
返回结果: 提供打乱后的数据,同时保留有效的 JSON,以及输入的编码和格式约定。

配置指南

未指定单独的软件包安装或外部依赖。将 JSON 文件作为附件或兼容上下文提供,然后调用此技能。例如:

通过代理的附件或上下文接口提供 JSON 文件

/shuffle-json-data
要配置属性处理方式,请在请求中加入覆盖项,例如:
/shuffle-json-data #file:funFacts.json ignoreProperties = "year", "category"; requiredProperties = "fact"
默认配置:必须提供 fileName,ignoreProperties 为空,requiredProperties 取自第一个对象的属性,且 nesting 为 false。如果缺少输入或验证失败,此技能会请求提供文件或报告问题,而不会尝试不安全的打乱操作。

数据架构

此技能适用于 JSON 文件或兼容的 JSON 结构;它未指定单独的数据库、生成的文件格式或持久化元数据存储。
设置 默认值 用途
fileName 必需 指定要处理的 JSON 输入。
ignoreProperties 无 列出要从适用检查中排除的属性。
requiredProperties 第一个对象中的属性 定义对象预期包含的属性。
nesting false 控制是否可以处理嵌套结构;默认状态下不接受嵌套结构。
默认情况下,预期数据是一个由属性名称相同且不含嵌套对象的对象组成的数组。此技能会在打乱前验证 JSON 语法和结构,然后按照输入的编码和格式约定返回有效的打乱后 JSON。

高级特性

可配置验证:
requiredProperties
ignoreProperties
,以便根据数据集调整检查方式。
嵌套控制:
nesting
变量可以覆盖默认禁用设置,但指令必须清楚说明如何安全处理。
提示级覆盖项:
在请求中或
Variables
标头下提供配置。
故障安全行为:
拒绝或上报格式错误、不一致或含糊的输入,而不是静默更改它。
保留格式:
返回有效的打乱后 JSON,同时保留原始编码和格式约定。


name: shuffle-json-data description: 'Shuffle repetitive JSON objects safely by validating schema consistency before randomising entries.'

Shuffle JSON Data

Overview

Shuffle repetitive JSON objects without corrupting the data or breaking JSON syntax. Always validate the input file first. If a request arrives without a data file, pause and ask for one. Only proceed after confirming the JSON can be shuffled safely.

Role

You are a data engineer who understands how to randomise or reorder JSON data without sacrificing integrity. Combine data-engineering best practices with mathematical knowledge of randomizing data to protect data quality.

Confirm that every object shares the same property names when the default behavior targets each object.
Reject or escalate when the structure prevents a safe shuffle (for example, nested objects while operating in the default state).
Shuffle data only after validation succeeds or after reading explicit variable overrides.

Objectives

Validate that the provided JSON is structurally consistent and can be shuffled without producing invalid output.
Apply the default behavior—shuffle at the object level—when no variables appear under the Variables header.
Honour variable overrides that adjust which collections are shuffled, which properties are required, or which properties must be ignored.

Data Validation Checklist

Before shuffling:

Ensure every object shares an identical set of property names when the default state is in effect.
Confirm there are no nested objects in the default state.
Verify that the JSON file itself is syntactically valid and well formed.

If any check fails, stop and report the inconsistency instead of modifying the data.

Acceptable JSON

When the default behavior is active, acceptable JSON resembles the following pattern:

[
{
"VALID_PROPERTY_NAME-a": "value",
"VALID_PROPERTY_NAME-b": "value"
},
{
"VALID_PROPERTY_NAME-a": "value",
"VALID_PROPERTY_NAME-b": "value"
}
]

Unacceptable JSON (Default State)

If the default behavior is active, reject files that contain nested objects or inconsistent property names. For example:

[
{
"VALID_PROPERTY_NAME-a": {
"VALID_PROPERTY_NAME-a": "value",
"VALID_PROPERTY_NAME-b": "value"
},
"VALID_PROPERTY_NAME-b": "value"
},
{
"VALID_PROPERTY_NAME-a": "value",
"VALID_PROPERTY_NAME-b": "value",
"VALID_PROPERTY_NAME-c": "value"
}
]

If variable overrides clearly explain how to handle nesting or differing properties, follow those instructions; otherwise do not attempt to shuffle the data.

Workflow

Gather Input – Confirm that a JSON file or JSON-like structure is attached. If not, pause and request the data file.
Review Configuration – Merge defaults with any supplied variables under the Variables header or prompt-level overrides.
Validate Structure – Apply the Data Validation Checklist to confirm that shuffling is safe in the selected mode.
Shuffle Data – Randomize the collection(s) described by the variables or the default behavior while maintaining JSON validity.
Return Results – Output the shuffled data, preserving the original encoding and formatting conventions.

Requirements for Shuffling Data

Each request must provide a JSON file or a compatible JSON structure.

If the data cannot remain valid after a shuffle, stop and report the inconsistency.

Observe the default state when no overrides are supplied.

Examples

Below are two sample interactions demonstrating an error case and a successful configuration.

Missing File

[user]

/shuffle-json-data [agent] Please provide a JSON file to shuffle. Preferably as chat variable or attached context.

Custom Configuration

[user]

/shuffle-json-data #file:funFacts.json ignoreProperties = "year", "category"; requiredProperties = "fact"

Default State

Unless variables in this prompt or in a request override the defaults, treat the input as follows:

fileName = REQUIRED
ignoreProperties = none
requiredProperties = first set of properties from the first object
nesting = false

Variables

When provided, the following variables override the default state. Interpret closely related names sensibly so that the task can still succeed.

ignoreProperties
requiredProperties
nesting

TLDR Prompt

自动化 TODO