无论如何将compileUnit对象转换为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 对象。