@zjy4fun/json-open 0.2.1 → 0.3.1
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.
- package/.github/workflows/pages.yml +36 -0
- package/README.md +55 -103
- package/README.zh-CN.md +55 -100
- package/favicon.svg +4 -0
- package/index.html +1068 -0
- package/package.json +5 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Deploy to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
pages: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pages
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
deploy:
|
|
19
|
+
environment:
|
|
20
|
+
name: github-pages
|
|
21
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Setup Pages
|
|
27
|
+
uses: actions/configure-pages@v5
|
|
28
|
+
|
|
29
|
+
- name: Upload artifact
|
|
30
|
+
uses: actions/upload-pages-artifact@v3
|
|
31
|
+
with:
|
|
32
|
+
path: .
|
|
33
|
+
|
|
34
|
+
- name: Deploy to GitHub Pages
|
|
35
|
+
id: deployment
|
|
36
|
+
uses: actions/deploy-pages@v4
|
package/README.md
CHANGED
|
@@ -1,164 +1,116 @@
|
|
|
1
|
-
# json-open
|
|
1
|
+
# JSON Formatter (`json-open`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A fast, zero-dependency JSON formatter & viewer — CLI + Web.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Pipe JSON from terminal or paste it in the browser. Inspect instantly.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Why json-open?
|
|
12
|
-
|
|
13
|
-
Reading JSON in terminal is often painful:
|
|
14
|
-
|
|
15
|
-
- Long output is hard to scan
|
|
16
|
-
- Deep nesting is hard to understand quickly
|
|
17
|
-
- Full-featured tools can feel heavy for quick checks
|
|
18
|
-
|
|
19
|
-
`json-open` keeps it simple: **pipe JSON in, inspect it visually in seconds**.
|
|
9
|
+
**🌐 [Try it online →](https://zjy4fun.github.io/json-open/)**
|
|
20
10
|
|
|
21
11
|
---
|
|
22
12
|
|
|
23
13
|
## Features
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
- ✅ Read inline JSON text
|
|
27
|
-
- ✅ Open browser automatically (macOS / Linux / Windows)
|
|
28
|
-
- ✅ Collapsible tree view
|
|
29
|
-
- ✅ Expand all / Collapse all
|
|
30
|
-
- ✅ Local temp file rendering (no remote upload)
|
|
31
|
-
- ✅ **Auto-parse serialized JSON strings** (escaped/double-encoded)
|
|
32
|
-
- ✅ **Deep nested JSON string expansion** (auto-unwrap JSON strings inside objects)
|
|
15
|
+
### CLI
|
|
33
16
|
|
|
34
|
-
|
|
17
|
+
- Pipe from stdin: `curl ... | json`
|
|
18
|
+
- Inline JSON: `json '{"a":1}'`
|
|
19
|
+
- Auto-opens browser with interactive tree view
|
|
20
|
+
- Auto-parse serialized / double-encoded JSON strings
|
|
21
|
+
- Cross-platform (macOS / Linux / Windows)
|
|
35
22
|
|
|
36
|
-
|
|
23
|
+
### Web
|
|
37
24
|
|
|
38
|
-
|
|
25
|
+
- Paste or drag-and-drop JSON
|
|
26
|
+
- Collapsible tree with expand all / collapse all
|
|
27
|
+
- Real-time search with highlighting and keyboard navigation
|
|
28
|
+
- **Parse JSON strings toggle** — auto-expand embedded JSON with visual markers
|
|
29
|
+
- **Light / Dark theme** with localStorage persistence
|
|
30
|
+
- Resizable split panels
|
|
31
|
+
- No server, no upload — everything runs locally
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
npm i -g @zjy4fun/json-open
|
|
42
|
-
```
|
|
33
|
+
---
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
## Install (CLI)
|
|
45
36
|
|
|
46
37
|
```bash
|
|
47
|
-
json
|
|
38
|
+
npm i -g @zjy4fun/json-open
|
|
48
39
|
```
|
|
49
40
|
|
|
50
|
-
|
|
41
|
+
Or run once without installing:
|
|
51
42
|
|
|
52
43
|
```bash
|
|
53
44
|
npx @zjy4fun/json-open '{"hello":"world"}'
|
|
54
45
|
```
|
|
55
46
|
|
|
56
|
-
### Local development
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
git clone https://github.com/zjy4fun/json-open.git
|
|
60
|
-
cd json-open
|
|
61
|
-
npm install
|
|
62
|
-
npm link
|
|
63
|
-
```
|
|
64
|
-
|
|
65
47
|
---
|
|
66
48
|
|
|
67
49
|
## Quick Start
|
|
68
50
|
|
|
69
51
|
```bash
|
|
70
|
-
#
|
|
52
|
+
# API response
|
|
71
53
|
curl https://jsonplaceholder.typicode.com/todos/1 | json
|
|
72
54
|
|
|
73
|
-
#
|
|
74
|
-
json '{"
|
|
55
|
+
# Inline JSON
|
|
56
|
+
json '{"name":"test","list":[1,2,3]}'
|
|
75
57
|
|
|
76
|
-
#
|
|
77
|
-
cat
|
|
58
|
+
# File
|
|
59
|
+
cat data.json | json
|
|
78
60
|
```
|
|
79
61
|
|
|
80
|
-
The command opens your default browser and shows a structured JSON tree.
|
|
81
|
-
|
|
82
62
|
---
|
|
83
63
|
|
|
84
|
-
##
|
|
64
|
+
## Serialized JSON Strings
|
|
85
65
|
|
|
86
|
-
|
|
87
|
-
json [inline-json]
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Input sources:
|
|
91
|
-
|
|
92
|
-
- `stdin` (pipe)
|
|
93
|
-
- Inline JSON argument
|
|
66
|
+
A common pain point: JSON values that are themselves stringified JSON (from logs, databases, APIs).
|
|
94
67
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- `-v, --version` Show version
|
|
68
|
+
```bash
|
|
69
|
+
# Double-encoded
|
|
70
|
+
json '"{\"name\":\"test\"}"'
|
|
99
71
|
|
|
100
|
-
|
|
72
|
+
# Nested JSON string fields
|
|
73
|
+
json '{"data":"{\"users\":[{\"id\":1}]}"}'
|
|
101
74
|
|
|
102
|
-
|
|
103
|
-
json
|
|
104
|
-
json --version
|
|
105
|
-
json '{"ok":true}'
|
|
75
|
+
# Multi-level
|
|
76
|
+
json '"\"[1,2,3]\""'
|
|
106
77
|
```
|
|
107
78
|
|
|
108
|
-
|
|
79
|
+
`json-open` detects and unwraps these automatically. In the web viewer, toggle **Parse JSON strings** to expand them inline — parsed blocks are highlighted with a distinct background and border so you can tell what was originally a string.
|
|
109
80
|
|
|
110
81
|
---
|
|
111
82
|
|
|
112
|
-
##
|
|
113
|
-
|
|
114
|
-
`json-open` now automatically handles serialized/escaped JSON strings — a common pain point when working with logs, databases, and APIs.
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
# Double-encoded JSON string (e.g. from database or API response body)
|
|
118
|
-
json '"{\"name\":\"test\",\"age\":25}"'
|
|
119
|
-
# → auto-detects and parses as { "name": "test", "age": 25 }
|
|
120
|
-
|
|
121
|
-
# Nested JSON strings inside objects
|
|
122
|
-
json '{"status":"ok","data":"{\"users\":[{\"id\":1}]}"}'
|
|
123
|
-
# → auto-expands "data" field into a real JSON tree
|
|
83
|
+
## CLI Usage
|
|
124
84
|
|
|
125
|
-
|
|
126
|
-
json
|
|
127
|
-
|
|
85
|
+
```
|
|
86
|
+
json [json-string]
|
|
87
|
+
json -h | --help
|
|
88
|
+
json -v | --version
|
|
128
89
|
```
|
|
129
90
|
|
|
130
|
-
|
|
131
|
-
- Escaped JSON from `JSON.stringify()` output
|
|
132
|
-
- Log files with embedded JSON payloads
|
|
133
|
-
- API responses where a field contains a JSON string
|
|
134
|
-
- Database columns storing serialized JSON
|
|
91
|
+
Input: stdin (pipe) or inline argument. No input shows help.
|
|
135
92
|
|
|
136
93
|
---
|
|
137
94
|
|
|
138
|
-
##
|
|
95
|
+
## Web Usage
|
|
96
|
+
|
|
97
|
+
Open **[zjy4fun.github.io/json-open](https://zjy4fun.github.io/json-open/)** or `index.html` locally.
|
|
139
98
|
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
99
|
+
- Paste JSON in the left panel, click **Format** (or `Ctrl+Enter`)
|
|
100
|
+
- Use **Expand all / Collapse all** in the toolbar
|
|
101
|
+
- Search with `Ctrl+F` — navigate matches with `Enter` / `Shift+Enter`
|
|
102
|
+
- Toggle **Parse JSON strings** to expand embedded JSON (highlighted with amber markers)
|
|
103
|
+
- Switch theme with the 🌙/☀️ button in the header
|
|
145
104
|
|
|
146
105
|
---
|
|
147
106
|
|
|
148
107
|
## Contributing
|
|
149
108
|
|
|
150
|
-
Issues and PRs
|
|
151
|
-
|
|
152
|
-
### Good contribution ideas
|
|
153
|
-
|
|
154
|
-
- Better JSON parse error location hints
|
|
155
|
-
- Theme switch (light/dark)
|
|
156
|
-
- Direct file path support (e.g. `json ./data.json`)
|
|
157
|
-
- Search / highlight / copy JSON path
|
|
158
|
-
|
|
159
|
-
### Local dev
|
|
109
|
+
Issues and PRs welcome.
|
|
160
110
|
|
|
161
111
|
```bash
|
|
112
|
+
git clone https://github.com/zjy4fun/json-open.git
|
|
113
|
+
cd json-open
|
|
162
114
|
npm install
|
|
163
115
|
npm test
|
|
164
116
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -1,165 +1,120 @@
|
|
|
1
|
-
# json-open
|
|
1
|
+
# JSON Formatter (`json-open`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
快速、零依赖的 JSON 格式化 & 查看器 — CLI + Web 双模式。
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> 终端里管道输入,或浏览器里粘贴,立刻查看结构。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**🌐 [在线体验 →](https://zjy4fun.github.io/json-open/)**
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 功能
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### CLI
|
|
16
16
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
17
|
+
- 管道输入:`curl ... | json`
|
|
18
|
+
- 行内 JSON:`json '{"a":1}'`
|
|
19
|
+
- 自动打开浏览器展示交互式树形视图
|
|
20
|
+
- 自动解析序列化 / 双重转义的 JSON 字符串
|
|
21
|
+
- 跨平台(macOS / Linux / Windows)
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
### Web
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
- ✅ 一键全展开 / 全收起
|
|
31
|
-
- ✅ 本地临时文件渲染,不上传数据
|
|
32
|
-
- ✅ 跨平台打开浏览器(macOS / Linux / Windows)
|
|
25
|
+
- 粘贴或拖拽 JSON 文件
|
|
26
|
+
- 可折叠树形结构,一键全展开 / 全收起
|
|
27
|
+
- 实时搜索 + 高亮 + 键盘导航
|
|
28
|
+
- **解析 JSON 字符串开关** — 自动展开嵌套 JSON,展开部分有视觉标记
|
|
29
|
+
- **亮色 / 暗色主题切换**,自动记住偏好
|
|
30
|
+
- 可拖拽调整左右面板大小
|
|
31
|
+
- 纯本地运行,不上传任何数据
|
|
33
32
|
|
|
34
33
|
---
|
|
35
34
|
|
|
36
|
-
##
|
|
37
|
-
|
|
38
|
-
### 方式一:GitHub Packages(当前主分发)
|
|
39
|
-
|
|
40
|
-
先配置 npm 使用 GitHub Packages:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
echo "@zjy4fun:registry=https://npm.pkg.github.com" >> ~/.npmrc
|
|
44
|
-
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> ~/.npmrc
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
然后安装:
|
|
35
|
+
## 安装(CLI)
|
|
48
36
|
|
|
49
37
|
```bash
|
|
50
38
|
npm i -g @zjy4fun/json-open
|
|
51
39
|
```
|
|
52
40
|
|
|
53
|
-
|
|
41
|
+
免安装直接用:
|
|
54
42
|
|
|
55
43
|
```bash
|
|
56
|
-
|
|
57
|
-
cd json-open
|
|
58
|
-
npm install
|
|
59
|
-
npm link
|
|
44
|
+
npx @zjy4fun/json-open '{"hello":"world"}'
|
|
60
45
|
```
|
|
61
46
|
|
|
62
|
-
安装后可全局使用 `json` 命令。
|
|
63
|
-
|
|
64
47
|
---
|
|
65
48
|
|
|
66
49
|
## 快速开始
|
|
67
50
|
|
|
68
51
|
```bash
|
|
69
|
-
#
|
|
52
|
+
# API 返回
|
|
70
53
|
curl https://jsonplaceholder.typicode.com/todos/1 | json
|
|
71
54
|
|
|
72
|
-
#
|
|
73
|
-
json '{"
|
|
55
|
+
# 行内 JSON
|
|
56
|
+
json '{"name":"test","list":[1,2,3]}'
|
|
74
57
|
|
|
75
|
-
#
|
|
76
|
-
cat
|
|
58
|
+
# 文件
|
|
59
|
+
cat data.json | json
|
|
77
60
|
```
|
|
78
61
|
|
|
79
|
-
执行后会自动打开浏览器,展示 JSON 树形视图。
|
|
80
|
-
|
|
81
62
|
---
|
|
82
63
|
|
|
83
|
-
##
|
|
84
|
-
|
|
85
|
-
1. **API 调试**
|
|
86
|
-
快速查看接口返回结构,尤其是深层嵌套数据。
|
|
87
|
-
|
|
88
|
-
2. **前后端联调**
|
|
89
|
-
接口变更后快速确认字段缺失或类型异常。
|
|
90
|
-
|
|
91
|
-
3. **临时数据检查**
|
|
92
|
-
对日志、队列、快照中的 JSON 做可视化排查。
|
|
64
|
+
## 序列化 JSON 字符串
|
|
93
65
|
|
|
94
|
-
|
|
95
|
-
与同事讨论 payload 时更直观。
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 命令行为
|
|
66
|
+
常见痛点:JSON 值本身又是一个字符串化的 JSON(来自日志、数据库、API 响应)。
|
|
100
67
|
|
|
101
68
|
```bash
|
|
102
|
-
|
|
103
|
-
|
|
69
|
+
# 双重编码
|
|
70
|
+
json '"{\"name\":\"test\"}"'
|
|
104
71
|
|
|
105
|
-
|
|
72
|
+
# 嵌套 JSON 字符串字段
|
|
73
|
+
json '{"data":"{\"users\":[{\"id\":1}]}"}'
|
|
106
74
|
|
|
107
|
-
|
|
108
|
-
|
|
75
|
+
# 多层序列化
|
|
76
|
+
json '"\"[1,2,3]\""'
|
|
77
|
+
```
|
|
109
78
|
|
|
110
|
-
|
|
79
|
+
`json-open` 自动检测并解包。在 Web 界面中开启 **Parse JSON strings** 开关,展开的嵌套块会用琥珀色背景和左边框标记,一眼区分哪些是从字符串解析出来的。
|
|
111
80
|
|
|
112
|
-
|
|
113
|
-
- `-v, --version` 显示版本
|
|
81
|
+
---
|
|
114
82
|
|
|
115
|
-
|
|
83
|
+
## CLI 用法
|
|
116
84
|
|
|
117
|
-
```
|
|
118
|
-
json
|
|
119
|
-
json --
|
|
120
|
-
json
|
|
85
|
+
```
|
|
86
|
+
json [json-string]
|
|
87
|
+
json -h | --help
|
|
88
|
+
json -v | --version
|
|
121
89
|
```
|
|
122
90
|
|
|
123
|
-
|
|
91
|
+
输入来源:stdin(管道)或命令行参数。无输入时显示帮助。
|
|
124
92
|
|
|
125
93
|
---
|
|
126
94
|
|
|
127
|
-
##
|
|
95
|
+
## Web 用法
|
|
128
96
|
|
|
129
|
-
|
|
97
|
+
打开 **[zjy4fun.github.io/json-open](https://zjy4fun.github.io/json-open/)** 或本地 `index.html`。
|
|
130
98
|
|
|
131
|
-
- `
|
|
132
|
-
-
|
|
133
|
-
- `
|
|
134
|
-
|
|
135
|
-
|
|
99
|
+
- 左侧面板粘贴 JSON,点击 **Format**(或 `Ctrl+Enter`)
|
|
100
|
+
- 工具栏 **Expand all / Collapse all** 控制展开
|
|
101
|
+
- `Ctrl+F` 搜索 — `Enter` / `Shift+Enter` 跳转匹配项
|
|
102
|
+
- 开启 **Parse JSON strings** 展开嵌套 JSON(琥珀色标记)
|
|
103
|
+
- 右上角 🌙/☀️ 切换主题
|
|
136
104
|
|
|
137
105
|
---
|
|
138
106
|
|
|
139
107
|
## 参与贡献
|
|
140
108
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
### 建议贡献方向
|
|
144
|
-
|
|
145
|
-
- 更好的错误提示(如 JSON 语法错误定位)
|
|
146
|
-
- 主题切换(亮色/暗色)
|
|
147
|
-
- 支持直接读取文件路径(如 `json ./data.json`)
|
|
148
|
-
- 更丰富交互(搜索、高亮、复制 JSON Path)
|
|
149
|
-
|
|
150
|
-
### 本地开发
|
|
109
|
+
欢迎 Issue / PR。
|
|
151
110
|
|
|
152
111
|
```bash
|
|
112
|
+
git clone https://github.com/zjy4fun/json-open.git
|
|
113
|
+
cd json-open
|
|
153
114
|
npm install
|
|
154
115
|
npm test
|
|
155
116
|
```
|
|
156
117
|
|
|
157
|
-
提交前建议:
|
|
158
|
-
|
|
159
|
-
- 确保代码可运行
|
|
160
|
-
- 确保 README 示例可复现
|
|
161
|
-
- 改动保持聚焦、清晰
|
|
162
|
-
|
|
163
118
|
---
|
|
164
119
|
|
|
165
120
|
## 许可证
|
package/favicon.svg
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#1e293b"/>
|
|
3
|
+
<text x="32" y="44" text-anchor="middle" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="36" font-weight="700" fill="#e2e8f0">{ }</text>
|
|
4
|
+
</svg>
|