AgentSkillsCN

JSON Transform CLI

在Node.js中实现类似jq的JSON处理功能。查询、重塑、扁平化、差异比较以及转换JSON数据。这是jq的JavaScript原生替代方案。

SKILL.md
--- frontmatter
name: JSON Transform CLI
description: Transform JSON like jq but in Node.js. Query, reshape, flatten, diff, and convert JSON data. JavaScript-native alternative to jq.
tags: [json, transform, jq, query, flatten, diff, cli, data-processing]

JSON Transform CLI

Transform JSON like a pro. jq-alternative for Node.js developers.

Query. Reshape. Flatten. Diff. Convert.

Quick Start

bash
npm install -g @lxgicstudios/jsonmorph
bash
# Extract field
jsonmorph '.users[].name' data.json

# Transform structure
jsonmorph '{names: .users[].name, count: .users | length}' data.json

# Flatten nested JSON
jsonmorph flatten deep.json

What It Does

Query

  • jq-like syntax
  • Deep property access
  • Array operations
  • Filtering and mapping

Transform

  • Reshape objects
  • Rename keys
  • Type conversion
  • Computed fields

Utilities

  • Flatten/unflatten
  • Diff two JSONs
  • Merge objects
  • Schema extraction

Commands

bash
# Query with path
jsonmorph '.data.items[0].name' file.json

# Filter array
jsonmorph '.users | filter(.age > 25)' file.json

# Map array
jsonmorph '.items | map({id, title})' file.json

# Flatten nested object
jsonmorph flatten nested.json

# Diff two files
jsonmorph diff old.json new.json

# Merge objects
jsonmorph merge base.json override.json

# Extract schema
jsonmorph schema data.json

Piping Support

bash
# From API response
curl https://api.example.com/data | jsonmorph '.results'

# Chain transforms
cat data.json | jsonmorph '.items' | jsonmorph 'map(.name)'

Why jsonmorph?

  • JavaScript-native - No need to learn jq syntax
  • Familiar - Uses JS-like expressions
  • Fast - Streaming support for large files
  • No deps - Pure Node.js

Built by LXGIC Studios

🔗 GitHub · Twitter