无论如何将compilationUnit对象转换为json?
String src = """
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
@Entity()
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(color: Colors.cyan),
child: (new Center(child: new Text("Hello"))));
}
}""";
var ast = parseCompilationUnit(src, parseFunctionBodies: true);
我正在使用此方法获取dart代码的ast,我希望它将其转换为json对象。