Skip to content

Commit 5a23fd8

Browse files
committed
v0.3
1 parent afad6b4 commit 5a23fd8

12 files changed

Lines changed: 1025 additions & 257 deletions

README.md

Lines changed: 151 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,95 @@ jfe --help # Show help and all options
4242
jfe --version # Show version
4343
jfe --max-depth 3 file.json # Limit analysis to 3 levels deep
4444
jfe --quiet file.json # Suppress output (useful for benchmarking)
45+
jfe --stats file.json # Show detailed statistics for field values
46+
jfe --interactive file.json # Start interactive exploration mode
4547
```
4648

49+
### Advanced Features
50+
51+
#### Enum Detection
52+
When jfe detects that a field has a small number of unique values (≤10 by default), it displays them as an enum:
53+
54+
```bash
55+
$ jfe users.json
56+
.users[].status: enum ["active", "inactive", "pending"] (3 values)
57+
.users[].role: enum ["admin", "user"] (2 values)
58+
```
59+
60+
#### Statistics Mode (`--stats`)
61+
Get detailed statistical information about field values:
62+
63+
```bash
64+
$ jfe --stats products.json
65+
.products[].price: number (5 total, min: 24.99, max: 129.99, avg: 74.99, sum: 374.95)
66+
.products[].name: string (5 total, unique: 5, avgLen: 13.4, most common: "Widget" (2x))
67+
.products[].inStock: boolean (5 total, true: 4, false: 1)
68+
```
69+
70+
#### Interactive Mode (`--interactive`)
71+
Explore JSON structures interactively with filtering, sorting, and real-time analysis:
72+
73+
```bash
74+
$ jfe --interactive data.json
75+
🔍 JSON Field Explorer - Interactive Mode
76+
Type 'help' for available commands, 'exit' to quit
77+
78+
Showing 15 field(s):
79+
.company: object
80+
.company.name: string
81+
.company.employees: array (size: 100)
82+
...
83+
84+
jfe> help
85+
Available commands:
86+
help - Show this help message
87+
list - Show all fields (current view)
88+
filter <pattern> - Filter fields by path pattern (regex supported)
89+
sort <method> - Sort by: path, type, alpha
90+
stats - Toggle statistics mode
91+
depth <number> - Set max depth (use 'all' for unlimited)
92+
search <term> - Quick search for fields containing term
93+
count - Show count of current results
94+
reset - Reset all filters and settings
95+
exit - Exit interactive mode
96+
97+
jfe> filter employees
98+
Showing 8 field(s):
99+
.company.employees: array (size: 100)
100+
.company.employees[]: object
101+
.company.employees[].name: string
102+
...
103+
104+
jfe> stats
105+
Statistics mode: ON
106+
.company.employees[].age: number (100 total, min: 22, max: 65, avg: 41.2, sum: 4120)
107+
.company.employees[].salary: number (100 total, min: 35000, max: 150000, avg: 72500)
108+
109+
jfe> search address
110+
Filter set to: address
111+
.company.employees[].address: object
112+
.company.employees[].address.street: string
113+
.company.employees[].address.city: string
114+
115+
jfe> exit
116+
Goodbye! 👋
117+
```
118+
119+
##### Interactive Commands Reference
120+
121+
| Command | Description | Examples |
122+
|---------|-------------|----------|
123+
| `help` | Show available commands | `help` |
124+
| `list` | Display current filtered view | `list` |
125+
| `filter <pattern>` | Filter by regex or string pattern | `filter users\[\]`, `filter address` |
126+
| `search <term>` | Quick search (alias for filter) | `search email`, `search phone` |
127+
| `sort <method>` | Sort results (`path`, `type`, `alpha`) | `sort type`, `sort alpha` |
128+
| `stats` | Toggle statistics mode on/off | `stats` |
129+
| `depth <n>` | Set max depth or `all` | `depth 3`, `depth all` |
130+
| `count` | Show number of matching fields | `count` |
131+
| `reset` | Clear all filters and settings | `reset` |
132+
| `exit` | Exit interactive mode | `exit` or `quit` |
133+
47134
# Examples
48135

49136
Given a JSON file like this:
@@ -94,17 +181,66 @@ This output indicates that the JSON file contains fields for the organization's
94181

95182
# Roadmap
96183

97-
For future roadmap, features that could be implemented are;
184+
## ✅ Completed Features
185+
186+
- **CLI Framework**: Proper argument parsing with commander.js
187+
- **Enhanced Options**: `--help`, `--version`, `--max-depth`, `--quiet` flags
188+
- **Enum Detection**: Automatic detection of fields with limited unique values
189+
- **Statistics Mode**: `--stats` for detailed field analysis (min/max/avg, string lengths, frequencies)
190+
- **Interactive Mode**: `--interactive` with filtering, sorting, and real-time exploration
191+
- **Optional Field Detection**: Shows when array elements have inconsistent fields
192+
- **Error Handling**: Comprehensive error messages and file validation
193+
- **Test Coverage**: 34+ tests covering all features
194+
- **Demo Scripts**: Ready-to-run examples
98195

99-
- Show types in order of usage.
100-
- Show enum if variation is small in type.
101-
- Provide a "stat" command to show statistics about the values. Like most common strings (if enum), or min/max/average for numbers.
196+
## 🚀 Future Development Ideas
102197

103-
If you want to contribute with any of these, feel free to send a PR!
198+
### Phase 3: Output & Integration
199+
- **Multiple Output Formats**: JSON, CSV, XML output options
200+
- **Path Filtering**: `--filter` and `--exclude` pattern matching
201+
- **Color Output**: Syntax highlighting with chalk
202+
- **Progress Indicators**: For large file processing
104203

105-
# Testing
204+
### Advanced Analysis
205+
- **Pattern Recognition**: Detect emails, URLs, dates, UUIDs automatically
206+
- **Schema Generation**: Generate JSON Schema, TypeScript interfaces
207+
- **File Comparison**: Compare structures between JSON files
208+
- **Performance**: Streaming parser for very large files (>1GB)
106209

107-
Test files are included in `/test`. To run test:
210+
### Developer Integration
211+
- **Programmatic API**: Node.js module for integration
212+
- **VS Code Extension**: IDE integration for JSON files
213+
- **Configuration**: Support for `.jferc` config files
214+
- **Plugin System**: Extensible architecture for custom analyzers
215+
216+
### Community & Distribution
217+
- **Package Managers**: Homebrew, Chocolatey, Docker image
218+
- **Documentation**: Video tutorials, comprehensive guides
219+
- **CI/CD**: GitHub Actions, automated releases
220+
221+
*Want to contribute? Pick any feature above and send a PR! Check the issues for discussion on specific features.*
222+
223+
# Testing & Demos
224+
225+
## Running Tests
226+
227+
```bash
228+
npm test # Run unit tests
229+
npm run demo # Run all feature demos
230+
```
231+
232+
## Demo Scripts
233+
234+
Try out the different features with our sample data:
235+
236+
```bash
237+
npm run demo:enum # See enum detection in action
238+
npm run demo:stats # See statistics mode
239+
npm run demo:complex # Complex nested structure analysis
240+
npm run demo:interactive # Interactive mode (requires manual input)
241+
```
242+
243+
Test files are included in `/test`. To run tests:
108244

109245
```bash
110246
npm test
@@ -130,6 +266,14 @@ Current benchmark results:
130266

131267
# Changelog
132268

269+
## v0.3.0 🎉
270+
-**Enum Detection**: Automatically detects and displays fields with limited unique values as enums
271+
-**Statistics Mode**: Added `--stats` flag for detailed field analysis (min/max/avg for numbers, length stats for strings, etc.)
272+
-**Interactive Mode**: Added `--interactive` flag for real-time JSON exploration with filtering, sorting, and search
273+
-**Demo Scripts**: Added npm run demo scripts to showcase different features
274+
-**Comprehensive Tests**: 34 passing tests covering all features
275+
-**Enhanced Documentation**: Complete documentation for all features and interactive commands
276+
133277
## v0.2.0
134278
-**CLI Framework**: Added proper CLI argument parsing with commander.js
135279
-**New Options**: Added `--version`, `--help`, `--max-depth`, `--quiet` flags

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Command } from "commander";
33
import { processJson } from "./jfe.js";
44
import { readFile } from "./file.js";
5+
import { startInteractiveMode } from "./interactive.js";
56
import { readFileSync } from "fs";
67
import { fileURLToPath } from "url";
78
import { dirname, join } from "path";
@@ -23,10 +24,17 @@ program
2324
.option("-f, --format <type>", "output format", "text")
2425
.option("--max-depth <number>", "maximum recursion depth", parseInt)
2526
.option("-q, --quiet", "suppress output (useful for benchmarking)")
27+
.option("-s, --stats", "show detailed statistics for field values")
28+
.option("-i, --interactive", "start interactive exploration mode")
2629
.action(async (file, options) => {
2730
try {
2831
const json = file ? readFile(file) : await parseStdin();
29-
processJson(json, options);
32+
33+
if (options.interactive) {
34+
startInteractiveMode(json, options);
35+
} else {
36+
processJson(json, options);
37+
}
3038
} catch (error) {
3139
console.error("Error:", error.message);
3240
process.exit(1);

0 commit comments

Comments
 (0)