A small command-line JSON explorer with a path-based query language (jq-lite). Load a JSON file, inspect its shape, and pull out values interactively or from scripts.
cmake -S . -B build
cmake --build build
./build/json_parser mine.jsonAt the json> prompt:
json> structure 2
json> players[0].player
json> players[*].player
json> help
json> exit
./json_parser path/to/file.json- Type a query to print matching values as JSON.
- Type a meta-command (
help,print,structure, …) for REPL actions. - Press Tab for autocomplete (fields, array indices, string keys).
- Use Up/Down for history.
- Invalid queries print an error and the REPL keeps running.
Run a single query and exit — useful for scripts and pipes:
./json_parser mine.json -q 'players[0].player'
./json_parser mine.json -q 'players[*].inventory[*].item'Exit code is non-zero if the query fails.
| Command | Description |
|---|---|
help |
Show query syntax and commands |
print or . |
Dump the full loaded JSON |
structure or tree |
Folder-tree view of the file (keys, types, counts) |
structure 3 or tree 3 |
Same, but limit depth (handy for large files) |
clear |
Clear the screen |
exit |
Quit |
The structure view uses colors: blue {n} for objects, green [n] for arrays, and dimmed previews for leaf values.
Queries are a chain of steps applied left to right:
| Step | Example | Meaning |
|---|---|---|
| Field | players |
Object member by name |
| Dot + field | .player |
Same (dot is optional between steps) |
| Array index | [0] |
Element at index |
| Array wildcard | [*] |
Every element |
| String key | ["meta"] |
Object member by string key |
Examples (using mine.json):
players # the players array
players[0] # first player object
players[0].player # "Steve"
players[0].location # location object
players[0].inventory[0].item # "Diamond Sword"
players[*].player # all player names
players[0]["settings"].gamemode # string-key access
Each matching value is printed as valid JSON on its own line.
While typing a query, press Tab to see suggestions based on the loaded file:
- Object fields after
.or at the start of a step - Array indices after
[ - String keys inside
["…"]
Suggestions show type hints (e.g. players[3], inventory{8}) and colors for objects vs arrays.
cmake -S . -B build
cmake --build build
ctest --test-dir buildRequires C++20, CMake, and replxx (for the REPL). See CMakeLists.txt for how replxx is located.
A multi-stage Dockerfile is included for containerized builds.
| Path | Role |
|---|---|
json/ |
JSON scanner, parser, AST, serializer |
Query/ |
Query scanner, parser, evaluator |
cmd/ |
Autocomplete, structure tree |
tests/ |
GoogleTest suite |
mine.json |
Sample file for trying queries |