Skip to main content

grepjson

Interactive JSON processor with built-in debugger

grepjson is a command-line tool designed to help developers interactively inspect and process JSON/JSONL data. It integrates Python's built-in pdb debugger, allowing you to explore JSON objects in real-time or execute custom Python snippets directly from the command line.

Features

  • Interactive Debugging: Drop into a pdb session to inspect JSON objects interactively.
  • JSONL Support: Process JSON Lines (JSONL) format with ease.
  • Custom Execution: Execute Python code snippets on JSON objects directly from the command line.
  • Cross-Platform: Works on UNIX-like systems and Windows (with some limitations).
  • Pipeline Integration: Seamlessly integrates with Unix pipelines and other CLI tools.

Installation

Install grepjson via pip:

pip install grepjson

Usage

Basic Usage

Parse a JSON file and enter an interactive debug session:

cat data.json | grepjson

In the debug session, access the parsed JSON object as obj:

(Pdb) print(obj['key'])

JSONL Support

Process a JSON Lines file and enter debug mode with all objects available as objs:

cat data.jsonl | grepjson --line

Or use a simple form:

cat data.jsonl | grepjson -l

Execute Code Snippets

Extract specific fields without entering debug mode:

cat data.json | grepjson --exec "print(obj['name'])"

Or use a simple form:

cat data.json | grepjson -x "print(obj['name'])"

Process each JSON object in a JSONL file:

cat data.jsonl | grepjson -l -x "print(obj['id'])"

Print Results

Automatically print the result of a code snippet:

cat data.json | grepjson -x "obj['value']" -p

Examples

Example 1: Interactive Debugging

echo '{"name": "Alice", "age": 30}' | grepjson

In the debug session:

(Pdb) print(obj['name'])
Alice
(Pdb) obj['age'] += 1
(Pdb) print(obj)
{'name': 'Alice', 'age': 31}

Example 2: JSONL Processing

echo -e '{"id": 1}\n{"id": 2}\n{"id": 3}' | grepjson -l -x "print(obj['id'])"

Output:

1
2
3

Example 3: Field Extraction

echo '{"name": "Bob", "details": {"age": 25}}' | grepjson -x "obj['details']['age']" -p

Output:

25

Release files for grepjson 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grepjson 0.2.2
File Size Uploaded
grepjson-0.2.2.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grepjson 0.2.2
File Interpreter ABI Platform
grepjson-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / grepjson-0.2.2.tar.gz

Download URL grepjson-0.2.2.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cfe10610009e166f201b1320066852fa9585f4c7854edfd971087fa5a6f4f0cb
BLAKE2b-256 checksum
How to use checksums
545d1c02043c52ff460e851b04901e3d73e3cc27f4bd1de409797ef59a9c2530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.0

Release files / grepjson-0.2.2-py3-none-any.whl

Download URL grepjson-0.2.2-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90199e173c60f1d864ed2d9e08b61f27c15ef2875b0c7d7592664009e268854c
BLAKE2b-256 checksum
How to use checksums
4fc375aae72988416d1732050c85cf9233c2a3bb4844cbb92df4514e510023be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page