agentleFS
NikoxkxNikoxkx/Agent-Skills/skills/data-analytics/json-transformer/SKILL.md

json-transformer

Skill1 starsChanged 5 months agoApache-2.0View on GitHub

Transforms, reshapes, and validates JSON data structures. Use when normalizing API responses, converting nested JSON to flat tables, or validating JSON against a schema.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write a schema (draft 2020-12 or 2019-09).

    line 53
  2. Very specific:

    Inconsistent nesting: Use errors='ignore' or try/except per record + dead letter.

    line 75
  3. Distinctive:

    Huge files: Never load the entire thing into memory.

    line 76
  4. Distinctive:

    Unicode / escaping issues: Ensure UTF-8 throughout.

    line 77
  5. Distinctive:

    Run the transformation on sample input — output shape matches expectation.

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

Transforms and validates JSON data using jq (CLI), Python (json, jsonpath-ng, pandas.json_normalize), and JSON Schema (jsonschema library). Covers common patterns: flattening nested objects/arrays, extracting specific fields, array of objects → table, schema validation, streaming large JSON files, and producing clean output for databases or downstream processing.

When to Use This Skill

  • Normalizing complex API responses (nested, inconsistent).
  • Converting JSON logs or documents into tabular form for analysis.
  • Validating incoming JSON payloads against a contract.
  • The user provides JSON files or describes JSON transformation needs.

Prerequisites

  • jq installed for CLI transformations (highly recommended).
  • Python with pandas, jsonschema, jsonpath-ng (optional but powerful).
  • The JSON data (file, API response, or stdin).

Steps

  1. Inspect the JSON:
    • jq '.' file.json | head -100 or Python json.load.
    • Identify the shape (object, array of objects, deeply nested).
  2. Choose tool by use case:
    • Simple reshaping / extraction: jq.
    • To pandas DataFrame: pandas.json_normalize.
    • Validation: JSON Schema + jsonschema.
    • Streaming large files: ijson (Python) or jq with --stream.
  3. Common jq patterns (provide ready-to-use one-liners):
    • Extract array: .items[]
    • Flatten nested: .user | {id, name, "address.city": .address.city}
    • Filter + map.
    • Group by.
  4. pandas.json_normalize:
    • pd.json_normalize(data, record_path=['results'], meta=['query']).
    • errors='ignore' for inconsistent structures.
  5. JSON Schema validation:
    • Write a schema (draft 2020-12 or 2019-09).
    • Validate in Python or with ajv (JS) / check-jsonschema (CLI).
    • Produce clear error messages with path to the bad field.
  6. Streaming large JSON:
    • For NDJSON (newline-delimited): process line by line.
    • For large arrays: use ijson.items(f, 'item').
  7. Output:
    • jq one-liners or script.
    • Python function transform_json(input_path) -> pd.DataFrame or list[dict].
    • JSON Schema file.
    • Example of before/after shape.

Examples

  • Normalize a complex GitHub API search response (nested user + repo objects) into a flat table using both jq and pandas.json_normalize.
  • Validate incoming webhook payloads against a strict schema and quarantine bad ones.
  • Stream-process a 500MB NDJSON log file and extract only error events.

Edge Cases & Error Handling

  • Inconsistent nesting: Use errors='ignore' or try/except per record + dead letter.
  • Huge files: Never load the entire thing into memory.
  • Unicode / escaping issues: Ensure UTF-8 throughout.

Verification

  1. Run the transformation on sample input — output shape matches expectation.
  2. Validate a good and a deliberately bad JSON — errors are clear and point to the bad field.
  3. For large files: memory usage stays reasonable (monitor with htop or similar).
  4. Re-run produces deterministic output.
  5. Success: JSON is turned into the exact shape needed for the next step, with validation protecting downstream systems.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.