py-json-analyzer 0.1.3__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. py_json_analyzer-0.2.0/PKG-INFO +416 -0
  2. py_json_analyzer-0.2.0/README.md +397 -0
  3. py_json_analyzer-0.2.0/json_explorer/__init__.py +1 -0
  4. py_json_analyzer-0.2.0/json_explorer/analyzer.py +227 -0
  5. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/cli.py +3 -1
  6. py_json_analyzer-0.2.0/json_explorer/codegen/__init__.py +178 -0
  7. py_json_analyzer-0.2.0/json_explorer/codegen/cli_integration.py +532 -0
  8. py_json_analyzer-0.2.0/json_explorer/codegen/core/__init__.py +41 -0
  9. py_json_analyzer-0.2.0/json_explorer/codegen/core/config.py +170 -0
  10. py_json_analyzer-0.2.0/json_explorer/codegen/core/generator.py +212 -0
  11. py_json_analyzer-0.2.0/json_explorer/codegen/core/naming.py +175 -0
  12. py_json_analyzer-0.2.0/json_explorer/codegen/core/schema.py +483 -0
  13. py_json_analyzer-0.2.0/json_explorer/codegen/core/templates.py +174 -0
  14. py_json_analyzer-0.2.0/json_explorer/codegen/interactive.py +710 -0
  15. py_json_analyzer-0.2.0/json_explorer/codegen/languages/__init__.py +35 -0
  16. py_json_analyzer-0.2.0/json_explorer/codegen/languages/go/__init__.py +42 -0
  17. py_json_analyzer-0.2.0/json_explorer/codegen/languages/go/config.py +115 -0
  18. py_json_analyzer-0.2.0/json_explorer/codegen/languages/go/generator.py +285 -0
  19. py_json_analyzer-0.2.0/json_explorer/codegen/languages/go/interactive.py +282 -0
  20. py_json_analyzer-0.2.0/json_explorer/codegen/languages/go/naming.py +81 -0
  21. py_json_analyzer-0.2.0/json_explorer/codegen/registry.py +355 -0
  22. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/interactive.py +31 -17
  23. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/main.py +60 -7
  24. py_json_analyzer-0.2.0/py_json_analyzer.egg-info/PKG-INFO +416 -0
  25. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/py_json_analyzer.egg-info/SOURCES.txt +16 -0
  26. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/py_json_analyzer.egg-info/requires.txt +4 -2
  27. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/pyproject.toml +6 -4
  28. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/setup.cfg +6 -4
  29. py_json_analyzer-0.1.3/PKG-INFO +0 -261
  30. py_json_analyzer-0.1.3/README.md +0 -244
  31. py_json_analyzer-0.1.3/json_explorer/__init__.py +0 -1
  32. py_json_analyzer-0.1.3/json_explorer/analyzer.py +0 -196
  33. py_json_analyzer-0.1.3/py_json_analyzer.egg-info/PKG-INFO +0 -261
  34. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/LICENSE +0 -0
  35. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/__main__.py +0 -0
  36. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/filter_parser.py +0 -0
  37. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/search.py +0 -0
  38. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/stats.py +0 -0
  39. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/tree_view.py +0 -0
  40. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/utils.py +0 -0
  41. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/json_explorer/visualizer.py +0 -0
  42. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/py_json_analyzer.egg-info/dependency_links.txt +0 -0
  43. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/py_json_analyzer.egg-info/entry_points.txt +0 -0
  44. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/py_json_analyzer.egg-info/top_level.txt +0 -0
  45. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/setup.py +0 -0
  46. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/__init__.py +0 -0
  47. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_analyzer.py +0 -0
  48. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_search.py +0 -0
  49. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_stats.py +0 -0
  50. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_tree_view.py +0 -0
  51. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_utils.py +0 -0
  52. {py_json_analyzer-0.1.3 → py_json_analyzer-0.2.0}/tests/test_visualizer.py +0 -0
@@ -0,0 +1,416 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-json-analyzer
3
+ Version: 0.2.0
4
+ Summary: A powerful CLI and Python library for analyzing, visualizing, exploring, and generating code from JSON data
5
+ Author: MS-32154
6
+ Author-email: MS-32154 <msttoffg@gmail.com>
7
+ License-Expression: MIT
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: requests
13
+ Requires-Dist: rich
14
+ Requires-Dist: matplotlib
15
+ Requires-Dist: dateparser
16
+ Requires-Dist: jinja2
17
+ Requires-Dist: windows-curses; sys_platform == "win32"
18
+ Dynamic: license-file
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/py-json-analyzer.svg)](https://pypi.org/project/py-json-analyzer/)
21
+ [![Python 3.9+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
22
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
23
+
24
+ # JSON Explorer
25
+
26
+ **JSON Explorer** is a powerful CLI and Python library for analyzing, visualizing, exploring, and generating code from JSON data.
27
+
28
+ ---
29
+
30
+ ## Features
31
+
32
+ ### Analysis & Exploration
33
+
34
+ - View JSON as a tree (compact, raw, or analytical)
35
+ - Search by key, value, key-value pairs, or custom filter expressions
36
+ - Generate statistical summaries and insights
37
+ - Create visualizations in terminal, browser, or matplotlib
38
+ - Interactive terminal exploration mode
39
+
40
+ ### Code Generation
41
+
42
+ - Generate strongly-typed data structures from JSON
43
+ - Multiple language support (Go, with Python, TypeScript, Rust coming soon)
44
+ - Smart type detection and conflict resolution
45
+ - Configurable naming conventions and templates
46
+ - JSON serialization tags and annotations
47
+ - Interactive configuration and preview
48
+
49
+ ### Library Features
50
+
51
+ - Usable as a Python library with modular components
52
+ - Extensible architecture for custom generators
53
+ - Template-based code generation
54
+ - Configuration profiles and validation
55
+
56
+ ---
57
+
58
+ ## Requirements
59
+
60
+ - Python >= 3.9
61
+
62
+ Required packages:
63
+
64
+ ```
65
+ numpy==2.3.2
66
+ requests==2.32.5
67
+ rich==14.1.0
68
+ setuptools==80.9.0
69
+ matplotlib==3.10.5
70
+ dateparser==1.2.2
71
+ jinja2>=3.0.0
72
+ ```
73
+
74
+ > Note: On Windows, the `windows-curses` package will be installed automatically to enable terminal UI features.
75
+
76
+ ---
77
+
78
+ ## Installation
79
+
80
+ ### From PyPI
81
+
82
+ ```bash
83
+ pip install py-json-analyzer
84
+ ```
85
+
86
+ Upgrade to the latest version:
87
+
88
+ ```bash
89
+ pip install --upgrade py-json-analyzer
90
+ ```
91
+
92
+ ### From Source
93
+
94
+ ```bash
95
+ git clone https://github.com/MS-32154/py-json-analyzer
96
+ cd json_explorer
97
+ pip install .
98
+ ```
99
+
100
+ ### Development Mode
101
+
102
+ ```bash
103
+ pip install -e .
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Running Tests
109
+
110
+ ```bash
111
+ pytest
112
+ ```
113
+
114
+ ---
115
+
116
+ ## CLI Usage
117
+
118
+ ```
119
+ json_explorer [-h] [--url URL] [--interactive] [--tree {compact,analysis,raw}]
120
+ [--search SEARCH] [--search-type {key,value,pair,filter}]
121
+ [--search-value SEARCH_VALUE] [--search-mode {exact,contains,regex,startswith,endswith,case_insensitive}]
122
+ [--tree-results] [--stats] [--detailed] [--plot] [--plot-format {terminal,matplotlib,browser,all}]
123
+ [--save-path SAVE_PATH] [--no-browser]
124
+ [--generate LANGUAGE] [--output FILE] [--config FILE] [--package-name NAME] [--root-name NAME]
125
+ [--list-languages] [--language-info LANGUAGE] [--verbose]
126
+ [file]
127
+
128
+ JSON Explorer - Analyze, visualize, explore, and generate code from JSON data
129
+
130
+ positional arguments:
131
+ file Path to JSON file
132
+
133
+ options:
134
+ -h, --help show this help message and exit
135
+ --url URL URL to fetch JSON from
136
+ --interactive, -i Run in interactive mode
137
+
138
+ analysis options:
139
+ --tree {compact,analysis,raw}
140
+ Display JSON tree structure
141
+ --stats Show statistics
142
+ --detailed Show detailed analysis/statistics
143
+
144
+ search options:
145
+ --search SEARCH Search query or filter expression
146
+ --search-type {key,value,pair,filter}
147
+ Type of search to perform
148
+ --search-value SEARCH_VALUE
149
+ Value to search for (used with --search-type pair)
150
+ --search-mode {exact,contains,regex,startswith,endswith,case_insensitive}
151
+ Search mode
152
+ --tree-results Display search results in tree format
153
+
154
+ visualization options:
155
+ --plot Generate visualizations
156
+ --plot-format {terminal,matplotlib,browser,all}
157
+ Visualization format
158
+ --save-path SAVE_PATH
159
+ Path to save visualizations
160
+ --no-browser Don't open browser for HTML visualizations
161
+
162
+ code generation options:
163
+ --generate LANGUAGE, -g LANGUAGE
164
+ Generate code in specified language
165
+ --output FILE, -o FILE
166
+ Output file for generated code (default: stdout)
167
+ --config FILE JSON configuration file for code generation
168
+ --package-name NAME Package/namespace name for generated code
169
+ --root-name NAME Name for the root data structure (default: Root)
170
+ --list-languages List supported target languages and exit
171
+ --language-info LANGUAGE
172
+ Show detailed information about a specific language
173
+ --verbose Show generation result metadata
174
+
175
+ common generation options:
176
+ --no-comments Don't generate comments in output code
177
+ --struct-case {pascal,camel,snake}
178
+ Case style for struct/class names
179
+ --field-case {pascal,camel,snake}
180
+ Case style for field names
181
+
182
+ Go-specific options:
183
+ --no-pointers Don't use pointers for optional fields in Go
184
+ --no-json-tags Don't generate JSON struct tags in Go
185
+ --no-omitempty Don't add omitempty to JSON tags in Go
186
+ --json-tag-case {original,snake,camel}
187
+ Case style for JSON tag names in Go
188
+ ```
189
+
190
+ ### Examples
191
+
192
+ **Basic Analysis:**
193
+
194
+ ```bash
195
+ json_explorer data.json --interactive
196
+ json_explorer data.json --tree compact --stats
197
+ json_explorer --url https://api.example.com/data --plot
198
+ ```
199
+
200
+ **Search Examples:**
201
+
202
+ ```bash
203
+ json_explorer data.json --search "name" --search-type key
204
+ json_explorer data.json --search "isinstance(value, int) and value > 10" --search-type filter
205
+ ```
206
+
207
+ **Code Generation Examples:**
208
+
209
+ ```bash
210
+ # List supported languages
211
+ json_explorer --list-languages
212
+
213
+ # Generate Go structs
214
+ json_explorer data.json --generate go
215
+
216
+ # Generate with custom configuration
217
+ json_explorer data.json --generate go --output models.go --package-name models
218
+
219
+ # Interactive code generation
220
+ json_explorer data.json --interactive # Then select code generation menu
221
+ ```
222
+
223
+ ### Screenshots
224
+
225
+ **Main Interactive Mode:**
226
+ ![interactive-mode](/screenshots/main.gif)
227
+
228
+ **Code Generation Interface:**
229
+ ![code generation interface - Go](/screenshots/codegen_go.gif)
230
+
231
+ ---
232
+
233
+ ## Library Usage
234
+
235
+ ### Analysis & Exploration
236
+
237
+ ```python
238
+ from json_explorer.stats import DataStatsAnalyzer
239
+ from json_explorer.analyzer import analyze_json
240
+ from json_explorer.search import JsonSearcher, SearchMode
241
+ from json_explorer.tree_view import print_json_analysis
242
+ from json_explorer.visualizer import JSONVisualizer
243
+
244
+ test_data = {
245
+ "users": [
246
+ {
247
+ "id": 1,
248
+ "name": "Alice",
249
+ "profile": {"age": 30, "settings": {"theme": "dark"}},
250
+ "tags": ["admin", "user"]
251
+ }
252
+ ],
253
+ "metadata": {"total": 1, "created": "2024-01-01"}
254
+ }
255
+
256
+ # Statistical analysis
257
+ analyzer = DataStatsAnalyzer()
258
+ analyzer.print_summary(test_data, detailed=True)
259
+
260
+ # Structure inference
261
+ summary = analyze_json(test_data)
262
+ print(summary)
263
+
264
+ # Search functionality
265
+ searcher = JsonSearcher()
266
+
267
+ results = searcher.search_keys(test_data, "settings", SearchMode.CONTAINS) # Search keys containing "settings"
268
+
269
+ results = searcher.search_values(test_data, "@", SearchMode.CONTAINS, value_types={str}) # Search for values containing '@'
270
+
271
+ results = searcher.search_key_value_pairs(
272
+ test_data,
273
+ key_pattern="tags",
274
+ value_pattern="user",
275
+ value_mode=SearchMode.CONTAINS,
276
+ ) # Searching for 'key' = 'tags' and values containing 'user'
277
+
278
+ results = searcher.search_with_filter(
279
+ test_data,
280
+ lambda k, v, d: isinstance(v, (int, float)) and v > 10
281
+ ) # Filter values > 10
282
+ searcher.print_results(results, show_tree=True)
283
+
284
+ # Tree visualization
285
+ print_json_analysis(test_data, "Sample Data", show_raw=True)
286
+
287
+ # Data visualizations
288
+ visualizer = JSONVisualizer()
289
+ visualizer.visualize(test_data, output="terminal", detailed=True) # 'terminal', 'matplotlib', or 'browser' output
290
+ ```
291
+
292
+ ### Code Generation
293
+
294
+ ```python
295
+ from json_explorer.codegen import (
296
+ generate_from_analysis,
297
+ quick_generate,
298
+ list_supported_languages,
299
+ get_language_info,
300
+ create_config
301
+ )
302
+ from json_explorer.analyzer import analyze_json
303
+
304
+ # Quick generation
305
+ go_code = quick_generate(test_data, language="go")
306
+ print(go_code)
307
+
308
+ # Detailed generation workflow
309
+ analysis = analyze_json(test_data)
310
+ config = create_config(
311
+ language="go",
312
+ package_name="models",
313
+ add_comments=True
314
+ )
315
+ result = generate_from_analysis(analysis, "go", config, "User")
316
+
317
+ if result.success:
318
+ print(result.code)
319
+ if result.warnings:
320
+ print("Warnings:", result.warnings)
321
+
322
+ # List available languages and info
323
+ languages = list_supported_languages()
324
+ print("Supported languages:", languages)
325
+
326
+ go_info = get_language_info("go")
327
+ print("Go generator info:", go_info)
328
+
329
+ # Interactive code generation
330
+ from json_explorer.codegen import create_interactive_handler
331
+
332
+ handler = create_interactive_handler(test_data)
333
+ handler.run_interactive() # Launches interactive interface
334
+ ```
335
+
336
+ ### Supported Languages
337
+
338
+ | Language | Status | Features |
339
+ | -------------- | --------------- | ------------------------------------------------ |
340
+ | **Go** | ✅ Full Support | Structs, JSON tags, pointers, configurable types |
341
+ | **Python** | 🚧 Coming Soon | Dataclasses, Pydantic models, type hints |
342
+ | **TypeScript** | 🚧 Coming Soon | Interfaces, types, optional properties |
343
+ | **Rust** | 🚧 Coming Soon | Structs, Serde annotations, Option types |
344
+
345
+ ### Code Generation Features
346
+
347
+ - **Smart Type Detection**: Handles mixed types, conflicts, and unknown values
348
+ - **Configurable Output**: Multiple templates and naming conventions
349
+ - **Language-Specific Options**: Tailored features for each target language
350
+ - **Validation & Warnings**: Comprehensive validation with helpful warnings
351
+ - **Template System**: Extensible Jinja2-based template architecture
352
+ - **Interactive Configuration**: Guided setup with preview and validation
353
+
354
+ ---
355
+
356
+ ## Configuration
357
+
358
+ ### Code Generation Config Example
359
+
360
+ ```json
361
+ {
362
+ "package_name": "models",
363
+ "add_comments": true,
364
+ "generate_json_tags": true,
365
+ "json_tag_omitempty": true,
366
+ "struct_case": "pascal",
367
+ "field_case": "pascal",
368
+ "use_pointers_for_optional": true,
369
+ "int_type": "int64",
370
+ "float_type": "float64"
371
+ }
372
+ ```
373
+
374
+ Load configuration:
375
+
376
+ ```bash
377
+ json_explorer data.json --generate go --config config.json
378
+ ```
379
+
380
+ ---
381
+
382
+ ## API Reference
383
+
384
+ For the complete API reference got to [JSON Explorer API Documentation](https://ms-32154.github.io/py-json-analyzer/) or see the source code.
385
+
386
+ ---
387
+
388
+ ## License
389
+
390
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
391
+
392
+ ## Contributing
393
+
394
+ Contributions are welcome! Please feel free to submit a Pull Request.
395
+
396
+ 1. Fork the repository
397
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
398
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
399
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
400
+ 5. Open a Pull Request
401
+
402
+ ## Support
403
+
404
+ If you encounter any issues or have questions, please:
405
+
406
+ 1. Check the [examples](#examples) section
407
+ 2. Search existing [GitHub Issues](https://github.com/MS-32154/py-json-analyzer/issues)
408
+ 3. Create a new issue with:
409
+ - Python version
410
+ - Operating system
411
+ - Minimal code example reproducing the issue
412
+ - Full error traceback (if applicable)
413
+
414
+ ---
415
+
416
+ **JSON Explorer** – © 2025 MS-32154. All rights reserved.