Skip to content

Commit 8a9b96d

Browse files
committed
顶层bean的默认构造既可以传json字符串,也可以传解析过生成的json对象了
1 parent 3621c69 commit 8a9b96d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def generate_code(work_bean):
222222
out_res += (line + '\n')
223223
if first and r'.fromParams({this.' in line:
224224
class_name = line.split(r'.fromParams({this.')[0].strip()
225-
out_res += '\n factory %s(jsonStr) => %s.fromJson(json.decode(jsonStr));\n' % (class_name, class_name)
225+
out_res += '\n factory %s(jsonStr) => jsonStr.runtimeType is String ? %s.fromJson(json.decode(jsonStr)) : %s.fromJson(jsonStr);\n' \
226+
% (class_name, class_name, class_name)
226227
first = False
227228
return out_res
228229

0 commit comments

Comments
 (0)