Skip to content

Instantly share code, notes, and snippets.

@PlugFox
Last active March 23, 2024 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlugFox/e74d16fbf4508fb1366ef2b4d2eab6e6 to your computer and use it in GitHub Desktop.
Save PlugFox/e74d16fbf4508fb1366ef2b4d2eab6e6 to your computer and use it in GitHub Desktop.
Dart StackOverflow
/*
* Dart StackOverflow
* https://gist.github.com/PlugFox/e74d16fbf4508fb1366ef2b4d2eab6e6
* https://dartpad.dev?id=e74d16fbf4508fb1366ef2b4d2eab6e6
* Mike Matiunin <plugfox@gmail.com>, 23 March 2024
*/
import 'dart:convert';
const depth = 10000;
// dart compile exe bin/main.dart -o main
void main() {
final buffer = StringBuffer();
for (var i = 0; i < depth; i++) {
buffer
..writeln('{')
..write(' ' * (i + 1))
..write('"node": ');
}
buffer.writeln('"eof"');
for (var i = depth; i > 0; i--) {
buffer
..write(' ' * (i - 1))
..writeln('}');
}
final json = buffer.toString();
//print(json.replaceAll(RegExp(r'\s+'), ' '));
final decoded = jsonDecode(json);
String? text;
try {
text = decoded.toString();
} on Object catch (error, stackTrace) {
print('Error: $error\n$stackTrace');
}
print(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment