-
-
Save PlugFox/51138ed9b05c91ccd77a6a8167e556aa to your computer and use it in GitHub Desktop.
Правки в парсер для @incker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Правки в парсер для @incker | |
import 'dart:async'; | |
import 'dart:convert'; | |
Future<String> queryOne() async => | |
"[1,2,3]"; | |
Future<String> queryTwo() async => | |
"{\"test\":true}"; | |
T parseJson<T>(String resp) { | |
const json = const JsonCodec(); | |
try { | |
return json.decode(resp); | |
} catch (e) { | |
print('Some error on parsing json: $e'); | |
return null; | |
} | |
} | |
void main() { | |
queryOne() | |
.then((String v) => parseJson<Map<String, dynamic>>(v)) | |
.then((Map<String, dynamic> v) => 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment