Skip to content

Commit ad5fc83

Browse files
committed
由于dart2升级api将JSON启用替换为json故作细微调整
1 parent 684318d commit ad5fc83

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Example/RegionResp.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RegionResp {
2020

2121
@override
2222
String toString() {
23-
return '{"code": $code,"ttl": $ttl,"message": ${message != null ? '${JSON
23+
return '{"code": $code,"ttl": $ttl,"message": ${message != null ? '${json
2424
.encode(message)}' : 'null'},"data": $data}';
2525
}
2626
}
@@ -113,14 +113,14 @@ class Arch {
113113
@override
114114
String toString() {
115115
return '{"aid": $aid,"attribute": $attribute,"copyright": $copyright,"ctime": $ctime,"duration": $duration,"pubdate": $pubdate,"state": $state,"tid": $tid,"videos": $videos,"desc": ${desc !=
116-
null ? '${JSON.encode(desc)}' : 'null'},"dynamic": ${dynamic != null
117-
? '${JSON.encode(dynamic)}'
116+
null ? '${json.encode(desc)}' : 'null'},"dynamic": ${dynamic != null
117+
? '${json.encode(dynamic)}'
118118
: 'null'},"pic": ${pic != null
119-
? '${JSON.encode(pic)}'
119+
? '${json.encode(pic)}'
120120
: 'null'},"title": ${title != null
121-
? '${JSON.encode(title)}'
121+
? '${json.encode(title)}'
122122
: 'null'},"tname": ${tname != null
123-
? '${JSON.encode(tname)}'
123+
? '${json.encode(tname)}'
124124
: 'null'},"owner": $owner,"rights": $rights,"stat": $stat}';
125125
}
126126
}
@@ -205,7 +205,7 @@ class Owner {
205205
String toString() {
206206
return '{"mid": $mid,"face": ${face != null
207207
? '${JSON.encode(face)}'
208-
: 'null'},"name": ${name != null ? '${JSON.encode(name)}' : 'null'}}';
208+
: 'null'},"name": ${name != null ? '${json.encode(name)}' : 'null'}}';
209209
}
210210
}
211211

tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def add_param_to_code(code, param):
104104
tcode = check_level_type(t)
105105

106106
if tcode == 2:
107-
code = code.replace(': $%s' % n, ': ${%s != null?\'${JSON.encode(%s)}\':\'null\'}' % (n, n))
107+
code = code.replace(': $%s' % n, ': ${%s != null?\'${json.encode(%s)}\':\'null\'}' % (n, n))
108108

109109
# dict类型处理,只需要修改construction中的输出方式
110110
elif tcode == 4:
@@ -185,7 +185,7 @@ def generate_code(work_bean):
185185

186186
# 最终修改,添加jsonStr解析为jsonRes代码
187187
bp = res.find('(jsonRes) {')
188-
return 'import \'dart:convert\';\n' + res[:bp] + '(jsonStr) {\n var jsonRes = JSON.decode(jsonStr);\n' + res[bp + 11:]
188+
return 'import \'dart:convert\' show json;\n' + res[:bp] + '(jsonStr) {\n var jsonRes = json.decode(jsonStr);\n' + res[bp + 11:]
189189

190190

191191
def check_and_generate_code(bean):

0 commit comments

Comments
 (0)