py-json-analyzer 0.1.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.
- py_json_analyzer-0.1.0/LICENSE +21 -0
- py_json_analyzer-0.1.0/PKG-INFO +275 -0
- py_json_analyzer-0.1.0/README.md +238 -0
- py_json_analyzer-0.1.0/json_explorer/__init__.py +1 -0
- py_json_analyzer-0.1.0/json_explorer/__main__.py +4 -0
- py_json_analyzer-0.1.0/json_explorer/analyzer.py +196 -0
- py_json_analyzer-0.1.0/json_explorer/cli.py +137 -0
- py_json_analyzer-0.1.0/json_explorer/filter_parser.py +132 -0
- py_json_analyzer-0.1.0/json_explorer/interactive.py +490 -0
- py_json_analyzer-0.1.0/json_explorer/main.py +163 -0
- py_json_analyzer-0.1.0/json_explorer/search.py +423 -0
- py_json_analyzer-0.1.0/json_explorer/stats.py +337 -0
- py_json_analyzer-0.1.0/json_explorer/tree_view.py +161 -0
- py_json_analyzer-0.1.0/json_explorer/utils.py +114 -0
- py_json_analyzer-0.1.0/json_explorer/visualizer.py +1053 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/PKG-INFO +275 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/SOURCES.txt +30 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/dependency_links.txt +1 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/entry_points.txt +2 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/requires.txt +4 -0
- py_json_analyzer-0.1.0/py_json_analyzer.egg-info/top_level.txt +2 -0
- py_json_analyzer-0.1.0/pyproject.toml +23 -0
- py_json_analyzer-0.1.0/setup.cfg +26 -0
- py_json_analyzer-0.1.0/setup.py +3 -0
- py_json_analyzer-0.1.0/tests/__init__.py +0 -0
- py_json_analyzer-0.1.0/tests/test_analyzer.py +85 -0
- py_json_analyzer-0.1.0/tests/test_search.py +192 -0
- py_json_analyzer-0.1.0/tests/test_stats.py +197 -0
- py_json_analyzer-0.1.0/tests/test_tree_view.py +188 -0
- py_json_analyzer-0.1.0/tests/test_utils.py +109 -0
- py_json_analyzer-0.1.0/tests/test_visualizer.py +96 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MS-32154
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-json-analyzer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Analyze, visualize, and explore JSON data from files or URLs
|
|
5
|
+
Author: MS-32154
|
|
6
|
+
Author-email: MS-32154 <msttoffg@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 MS-32154
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Requires-Python: >=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: rich
|
|
33
|
+
Requires-Dist: requests
|
|
34
|
+
Requires-Dist: matplotlib
|
|
35
|
+
Requires-Dist: numpy
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# ๐ JSON Explorer
|
|
39
|
+
|
|
40
|
+
**JSON Explorer** is a powerful CLI and Python library for analyzing, visualizing, and exploring JSON data from files, URLs, or Python objects.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ๐ฆ Features
|
|
45
|
+
|
|
46
|
+
- View JSON as a tree (compact, raw, or analytical)
|
|
47
|
+
- Search by key, value, key-value pairs, or custom filter expressions
|
|
48
|
+
- Generate statistical summaries and insights
|
|
49
|
+
- Create visualizations in terminal, browser, or matplotlib
|
|
50
|
+
- Interactive terminal exploration mode
|
|
51
|
+
- Usable as a Python library with modular components
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## ๐ฆ Requirements
|
|
56
|
+
|
|
57
|
+
- Python โฅ 3.7
|
|
58
|
+
|
|
59
|
+
- The following Python packages:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
numpy>=1.26.0
|
|
63
|
+
requests==2.32.4
|
|
64
|
+
rich==14.0.0
|
|
65
|
+
setuptools==80.9.0
|
|
66
|
+
matplotlib==3.10.3
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ๐ฅ Installation
|
|
72
|
+
|
|
73
|
+
### ๐น From PyPI
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install json-analyzer
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Upgrade to the latest version:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install --upgrade json-analyzer
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### ๐น From Source
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/MS-32154/json_explorer.git
|
|
89
|
+
cd json_explorer
|
|
90
|
+
pip install .
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### ๐น Development Mode
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install -e .
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## ๐ CLI Usage
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
json_explorer [-h] [--url URL] [--interactive] [--tree {compact,analysis,raw}] [--search SEARCH] [--search-type {key,value,pair,filter}]
|
|
105
|
+
[--search-value SEARCH_VALUE] [--search-mode {exact,contains,regex,startswith,endswith,case_insensitive}] [--tree-results] [--stats]
|
|
106
|
+
[--detailed] [--plot] [--plot-format {terminal,matplotlib,browser,all}] [--save-path SAVE_PATH] [--no-browser]
|
|
107
|
+
[file]
|
|
108
|
+
|
|
109
|
+
๐ JSON Explorer - Analyze, visualize, and explore JSON data
|
|
110
|
+
|
|
111
|
+
positional arguments:
|
|
112
|
+
file Path to JSON file
|
|
113
|
+
|
|
114
|
+
options:
|
|
115
|
+
-h, --help show this help message and exit
|
|
116
|
+
--url URL URL to fetch JSON from
|
|
117
|
+
--interactive, -i Run in interactive mode
|
|
118
|
+
--tree {compact,analysis,raw}
|
|
119
|
+
Display JSON tree structure
|
|
120
|
+
|
|
121
|
+
search options:
|
|
122
|
+
--search SEARCH Search query or filter expression
|
|
123
|
+
--search-type {key,value,pair,filter}
|
|
124
|
+
Type of search to perform
|
|
125
|
+
--search-value SEARCH_VALUE
|
|
126
|
+
Value to search for (used with --search-type pair)
|
|
127
|
+
--search-mode {exact,contains,regex,startswith,endswith,case_insensitive}
|
|
128
|
+
Search mode
|
|
129
|
+
--tree-results Display search results in tree format
|
|
130
|
+
|
|
131
|
+
analysis options:
|
|
132
|
+
--stats Show statistics
|
|
133
|
+
--detailed Show detailed analysis/statistics
|
|
134
|
+
|
|
135
|
+
visualization options:
|
|
136
|
+
--plot Generate visualizations
|
|
137
|
+
--plot-format {terminal,matplotlib,browser,all}
|
|
138
|
+
Visualization format
|
|
139
|
+
--save-path SAVE_PATH
|
|
140
|
+
Path to save visualizations
|
|
141
|
+
--no-browser Don't open browser for HTML visualizations
|
|
142
|
+
|
|
143
|
+
Examples:
|
|
144
|
+
json_explorer data.json --interactive
|
|
145
|
+
json_explorer data.json --tree compact --stats
|
|
146
|
+
json_explorer data.json --search "name" --search-type key
|
|
147
|
+
json_explorer data.json --search "isinstance(value, int) and value > 10" --search-type filter
|
|
148
|
+
json_explorer --url https://api.example.com/data --plot --tree-results
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## ๐ Library Usage
|
|
154
|
+
|
|
155
|
+
Use `json_explorer` as a Python module:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
test_data = {
|
|
159
|
+
"users": [
|
|
160
|
+
{
|
|
161
|
+
"id": 1,
|
|
162
|
+
"name": "Alice",
|
|
163
|
+
"profile": {
|
|
164
|
+
"age": 30,
|
|
165
|
+
"settings": {"theme": "dark", "notifications": True},
|
|
166
|
+
},
|
|
167
|
+
"tags": ["admin", "user"],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"id": 2,
|
|
171
|
+
"name": "Bob",
|
|
172
|
+
"profile": {
|
|
173
|
+
"age": 25,
|
|
174
|
+
"settings": {
|
|
175
|
+
"theme": "light",
|
|
176
|
+
"notifications": False,
|
|
177
|
+
"language": "en",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
"tags": ["user"],
|
|
181
|
+
"email": "bob@example.com",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
"metadata": {"total": 2, "created": "2024-01-01"},
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Stats Analysis
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
# Displays statistical summaries and structural analysis
|
|
192
|
+
from json_explorer.stats import DataStatsAnalyzer
|
|
193
|
+
|
|
194
|
+
analyzer = DataStatsAnalyzer()
|
|
195
|
+
analyzer.print_summary(test_data, detailed=True)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Structure Inference
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
# Generates a JSON Schema based on the first 20 instances of the largest top-level entity
|
|
202
|
+
from json_explorer.analyzer import analyze_json
|
|
203
|
+
|
|
204
|
+
summary = analyze_json(test_data)
|
|
205
|
+
print(summary)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Search Features
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from json_explorer.search import JsonSearcher, SearchMode
|
|
212
|
+
|
|
213
|
+
searcher = JsonSearcher()
|
|
214
|
+
|
|
215
|
+
# Search keys containing "settings"
|
|
216
|
+
results = searcher.search_keys(test_data, "settings", SearchMode.CONTAINS)
|
|
217
|
+
searcher.print_results(results)
|
|
218
|
+
|
|
219
|
+
# Search for values containing '@':"
|
|
220
|
+
results = searcher.search_values(test_data, "@", SearchMode.CONTAINS, value_types={str})
|
|
221
|
+
searcher.print_results(results)
|
|
222
|
+
|
|
223
|
+
# Searching for 'key' = 'tags' and values containing 'user':"
|
|
224
|
+
results = searcher.search_key_value_pairs(
|
|
225
|
+
test_data,
|
|
226
|
+
key_pattern="tags",
|
|
227
|
+
value_pattern="user",
|
|
228
|
+
value_mode=SearchMode.CONTAINS,
|
|
229
|
+
)
|
|
230
|
+
searcher.print_results(results, mode=SearchMode.CONTAINS)
|
|
231
|
+
|
|
232
|
+
# Filter values > 10
|
|
233
|
+
results = searcher.search_with_filter(
|
|
234
|
+
test_data,
|
|
235
|
+
lambda k, v, d: isinstance(v, (int, float)) and v > 10
|
|
236
|
+
)
|
|
237
|
+
searcher.print_results(results, show_tree=True)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Tree View
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
# Renders a tree view of the inferred JSON structure
|
|
244
|
+
# If show_raw is enabled, it also displays the raw JSON Schema
|
|
245
|
+
from json_explorer.tree_view import print_json_analysis, print_compact_tree
|
|
246
|
+
|
|
247
|
+
print_json_analysis(test_data, "Sample Data", show_raw=True)
|
|
248
|
+
print_compact_tree(test_data, "Sample Data (Compact)")
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Visualizations
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
Generates visual representations of statistics and insights
|
|
255
|
+
from json_explorer.visualizer import JSONVisualizer
|
|
256
|
+
|
|
257
|
+
visualizer = JSONVisualizer()
|
|
258
|
+
visualizer.visualize(test_data, output="terminal", detailed=True)
|
|
259
|
+
visualizer.visualize(test_data, output="matplotlib", detailed=True)
|
|
260
|
+
visualizer.visualize(test_data, output="browser", detailed=True)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## ๐งช Running Tests
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
pytest
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## ๐ License
|
|
274
|
+
|
|
275
|
+
MIT License. See `LICENSE` for details.
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# ๐ JSON Explorer
|
|
2
|
+
|
|
3
|
+
**JSON Explorer** is a powerful CLI and Python library for analyzing, visualizing, and exploring JSON data from files, URLs, or Python objects.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ฆ Features
|
|
8
|
+
|
|
9
|
+
- View JSON as a tree (compact, raw, or analytical)
|
|
10
|
+
- Search by key, value, key-value pairs, or custom filter expressions
|
|
11
|
+
- Generate statistical summaries and insights
|
|
12
|
+
- Create visualizations in terminal, browser, or matplotlib
|
|
13
|
+
- Interactive terminal exploration mode
|
|
14
|
+
- Usable as a Python library with modular components
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ๐ฆ Requirements
|
|
19
|
+
|
|
20
|
+
- Python โฅ 3.7
|
|
21
|
+
|
|
22
|
+
- The following Python packages:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
numpy>=1.26.0
|
|
26
|
+
requests==2.32.4
|
|
27
|
+
rich==14.0.0
|
|
28
|
+
setuptools==80.9.0
|
|
29
|
+
matplotlib==3.10.3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## ๐ฅ Installation
|
|
35
|
+
|
|
36
|
+
### ๐น From PyPI
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install json-analyzer
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Upgrade to the latest version:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install --upgrade json-analyzer
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### ๐น From Source
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/MS-32154/json_explorer.git
|
|
52
|
+
cd json_explorer
|
|
53
|
+
pip install .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### ๐น Development Mode
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install -e .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ๐ CLI Usage
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
json_explorer [-h] [--url URL] [--interactive] [--tree {compact,analysis,raw}] [--search SEARCH] [--search-type {key,value,pair,filter}]
|
|
68
|
+
[--search-value SEARCH_VALUE] [--search-mode {exact,contains,regex,startswith,endswith,case_insensitive}] [--tree-results] [--stats]
|
|
69
|
+
[--detailed] [--plot] [--plot-format {terminal,matplotlib,browser,all}] [--save-path SAVE_PATH] [--no-browser]
|
|
70
|
+
[file]
|
|
71
|
+
|
|
72
|
+
๐ JSON Explorer - Analyze, visualize, and explore JSON data
|
|
73
|
+
|
|
74
|
+
positional arguments:
|
|
75
|
+
file Path to JSON file
|
|
76
|
+
|
|
77
|
+
options:
|
|
78
|
+
-h, --help show this help message and exit
|
|
79
|
+
--url URL URL to fetch JSON from
|
|
80
|
+
--interactive, -i Run in interactive mode
|
|
81
|
+
--tree {compact,analysis,raw}
|
|
82
|
+
Display JSON tree structure
|
|
83
|
+
|
|
84
|
+
search options:
|
|
85
|
+
--search SEARCH Search query or filter expression
|
|
86
|
+
--search-type {key,value,pair,filter}
|
|
87
|
+
Type of search to perform
|
|
88
|
+
--search-value SEARCH_VALUE
|
|
89
|
+
Value to search for (used with --search-type pair)
|
|
90
|
+
--search-mode {exact,contains,regex,startswith,endswith,case_insensitive}
|
|
91
|
+
Search mode
|
|
92
|
+
--tree-results Display search results in tree format
|
|
93
|
+
|
|
94
|
+
analysis options:
|
|
95
|
+
--stats Show statistics
|
|
96
|
+
--detailed Show detailed analysis/statistics
|
|
97
|
+
|
|
98
|
+
visualization options:
|
|
99
|
+
--plot Generate visualizations
|
|
100
|
+
--plot-format {terminal,matplotlib,browser,all}
|
|
101
|
+
Visualization format
|
|
102
|
+
--save-path SAVE_PATH
|
|
103
|
+
Path to save visualizations
|
|
104
|
+
--no-browser Don't open browser for HTML visualizations
|
|
105
|
+
|
|
106
|
+
Examples:
|
|
107
|
+
json_explorer data.json --interactive
|
|
108
|
+
json_explorer data.json --tree compact --stats
|
|
109
|
+
json_explorer data.json --search "name" --search-type key
|
|
110
|
+
json_explorer data.json --search "isinstance(value, int) and value > 10" --search-type filter
|
|
111
|
+
json_explorer --url https://api.example.com/data --plot --tree-results
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ๐ Library Usage
|
|
117
|
+
|
|
118
|
+
Use `json_explorer` as a Python module:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
test_data = {
|
|
122
|
+
"users": [
|
|
123
|
+
{
|
|
124
|
+
"id": 1,
|
|
125
|
+
"name": "Alice",
|
|
126
|
+
"profile": {
|
|
127
|
+
"age": 30,
|
|
128
|
+
"settings": {"theme": "dark", "notifications": True},
|
|
129
|
+
},
|
|
130
|
+
"tags": ["admin", "user"],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": 2,
|
|
134
|
+
"name": "Bob",
|
|
135
|
+
"profile": {
|
|
136
|
+
"age": 25,
|
|
137
|
+
"settings": {
|
|
138
|
+
"theme": "light",
|
|
139
|
+
"notifications": False,
|
|
140
|
+
"language": "en",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
"tags": ["user"],
|
|
144
|
+
"email": "bob@example.com",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
"metadata": {"total": 2, "created": "2024-01-01"},
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Stats Analysis
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# Displays statistical summaries and structural analysis
|
|
155
|
+
from json_explorer.stats import DataStatsAnalyzer
|
|
156
|
+
|
|
157
|
+
analyzer = DataStatsAnalyzer()
|
|
158
|
+
analyzer.print_summary(test_data, detailed=True)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Structure Inference
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
# Generates a JSON Schema based on the first 20 instances of the largest top-level entity
|
|
165
|
+
from json_explorer.analyzer import analyze_json
|
|
166
|
+
|
|
167
|
+
summary = analyze_json(test_data)
|
|
168
|
+
print(summary)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Search Features
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from json_explorer.search import JsonSearcher, SearchMode
|
|
175
|
+
|
|
176
|
+
searcher = JsonSearcher()
|
|
177
|
+
|
|
178
|
+
# Search keys containing "settings"
|
|
179
|
+
results = searcher.search_keys(test_data, "settings", SearchMode.CONTAINS)
|
|
180
|
+
searcher.print_results(results)
|
|
181
|
+
|
|
182
|
+
# Search for values containing '@':"
|
|
183
|
+
results = searcher.search_values(test_data, "@", SearchMode.CONTAINS, value_types={str})
|
|
184
|
+
searcher.print_results(results)
|
|
185
|
+
|
|
186
|
+
# Searching for 'key' = 'tags' and values containing 'user':"
|
|
187
|
+
results = searcher.search_key_value_pairs(
|
|
188
|
+
test_data,
|
|
189
|
+
key_pattern="tags",
|
|
190
|
+
value_pattern="user",
|
|
191
|
+
value_mode=SearchMode.CONTAINS,
|
|
192
|
+
)
|
|
193
|
+
searcher.print_results(results, mode=SearchMode.CONTAINS)
|
|
194
|
+
|
|
195
|
+
# Filter values > 10
|
|
196
|
+
results = searcher.search_with_filter(
|
|
197
|
+
test_data,
|
|
198
|
+
lambda k, v, d: isinstance(v, (int, float)) and v > 10
|
|
199
|
+
)
|
|
200
|
+
searcher.print_results(results, show_tree=True)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Tree View
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
# Renders a tree view of the inferred JSON structure
|
|
207
|
+
# If show_raw is enabled, it also displays the raw JSON Schema
|
|
208
|
+
from json_explorer.tree_view import print_json_analysis, print_compact_tree
|
|
209
|
+
|
|
210
|
+
print_json_analysis(test_data, "Sample Data", show_raw=True)
|
|
211
|
+
print_compact_tree(test_data, "Sample Data (Compact)")
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Visualizations
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
Generates visual representations of statistics and insights
|
|
218
|
+
from json_explorer.visualizer import JSONVisualizer
|
|
219
|
+
|
|
220
|
+
visualizer = JSONVisualizer()
|
|
221
|
+
visualizer.visualize(test_data, output="terminal", detailed=True)
|
|
222
|
+
visualizer.visualize(test_data, output="matplotlib", detailed=True)
|
|
223
|
+
visualizer.visualize(test_data, output="browser", detailed=True)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## ๐งช Running Tests
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
pytest
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## ๐ License
|
|
237
|
+
|
|
238
|
+
MIT License. See `LICENSE` for details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|