File tree 3 files changed +27
-5
lines changed
3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 1
1
# JSONFormat4Flutter
2
2
受zzz40500/GsonFormat启发,将JSONObject格式的String解析成dart语言的实体类
3
3
4
- 用法:
4
+ ## 基本操作:
5
+
5
6
![ ] ( https://github.com/debuggerx01/JSONFormat4Flutter/blob/master/Example/json.gif?raw=true )
6
7
7
- ## MAC使用方法
8
+
9
+ ## 简易运行方式:
10
+ 在 [ Release] ( https://github.com/debuggerx01/JSONFormat4Flutter/releases ) 页面中,选择下载对应平台最新的二进制文件后——
11
+ #### linux:
12
+ 在程序目录打开终端后执行:sudo chmod u+x Formater_linux && ./Formater_linux
13
+ #### mac:
14
+ 在程序目录打开终端后执行:sudo chmod u+x Formater_mac && ./Formater_mac
15
+ #### windows:
16
+ 直接双击运行 Formater_win.exe
17
+ ## 源码运行(以MAC为例)
8
18
没有python运行环境的用户需要先安装python
9
19
10
20
mac中可以使用如下命令安装
@@ -18,6 +28,8 @@ brew 可以参考下面的链接
18
28
19
29
https://brew.sh/index_zh-cn
20
30
31
+
32
+
21
33
运行库的时候会可能会提示
22
34
```
23
35
Traceback (most recent call last):
@@ -34,5 +46,14 @@ ModuleNotFoundError: No module named 'PyQt5'
34
46
` pip3 install pyperclip `
35
47
等待安装完成
36
48
49
+ `` (注:brew安装最新版python3可能会出现ssl模块丢失导致pip3无法正常使用,此时也可以考虑直接在python官网下载pkg包方式安装python) ``
50
+
37
51
后面使用就是在命令行敲入
38
52
` python3 formater.py `
53
+
54
+ ## 已知问题
55
+ + mac下从文本框复制出的文字直接粘贴到 idea/android studio 中报错 " lllegal character '65279' "
56
+ ```
57
+ 参考 [issue1](https://github.com/debuggerx01/JSONFormat4Flutter/issues/1) ,如下图,使用5.7.1及之前版本的pyqt5
58
+ ```
59
+ ![ ] ( https://github.com/debuggerx01/JSONFormat4Flutter/blob/master/Example/pyqt571.png?raw=true )
Original file line number Diff line number Diff line change 8
8
from mainwindow import *
9
9
from tools import *
10
10
11
+ # 第三方库 用于解决跨平台的复制粘贴和复制的文本带bom问题
12
+ import pyperclip
13
+
11
14
# 定义显示的json格式化字符串的缩进量为4个空格
12
15
indent = ' '
13
16
@@ -199,8 +202,6 @@ def init_event():
199
202
200
203
201
204
def copy_left_text ():
202
- ## 第三方库 用于解决跨平台的复制粘贴和复制的文本带bom问题
203
- import pyperclip
204
205
text = ui .te_json .toPlainText ()
205
206
pyperclip .copy (text )
206
207
pass
Original file line number Diff line number Diff line change 7
7
import json
8
8
from PyQt5 .QtWidgets import QLabel , QComboBox , QMessageBox
9
9
10
- # 验证json字符串是否合法
11
10
from template_code import get_top_code_dict , get_list_code_loop
12
11
13
12
msg_box_ui = None
14
13
15
14
15
+ # 验证json字符串是否合法
16
16
def is_json (myjson ):
17
17
try :
18
18
json .loads (myjson )
You can’t perform that action at this time.
0 commit comments