diff --git a/cyberwow/lib/controller/rpc/rpc.dart b/cyberwow/lib/controller/rpc/rpc.dart index ede1dfa..5b4479a 100644 --- a/cyberwow/lib/controller/rpc/rpc.dart +++ b/cyberwow/lib/controller/rpc/rpc.dart @@ -58,6 +58,8 @@ Future rpcHTTP(String method) async { } } +dynamic jsonDecode(String responseBody) => json.decode(responseBody); + Future rpc(String method, {String field}) async { final response = await rpcHTTP(method); @@ -66,7 +68,8 @@ Future rpc(String method, {String field}) async { if (response.statusCode != 200) { return null; } else { - final _result = json.decode(response.body)['result']; + final _body = await compute(jsonDecode, response.body); + final _result = _body['result']; final _field = field == null ? _result : _result[field]; return _field; diff --git a/cyberwow/lib/controller/rpc/rpc2.dart b/cyberwow/lib/controller/rpc/rpc2.dart index 312db2b..19d178a 100644 --- a/cyberwow/lib/controller/rpc/rpc2.dart +++ b/cyberwow/lib/controller/rpc/rpc2.dart @@ -44,6 +44,8 @@ Future rpc2(String method) async { } } +dynamic jsonDecode(String responseBody) => json.decode(responseBody); + Future rpc2String(String method, {String field}) async { final response = await rpc2(method); @@ -52,7 +54,7 @@ Future rpc2String(String method, {String field}) async { if (response.statusCode != 200) { return ''; } else { - final _body= json.decode(response.body); + final _body = await compute(jsonDecode, response.body); final _field = field == null ? _body: _body[field]; return pretty(_field);