parseJson method

SCompilationUnit parseJson(
  1. String jsonString
)

Parses an AST from a JSON string.

The JSON should be in the format produced by tom_ast_generator's AstConverter.toJson() method.

Implementation

SCompilationUnit parseJson(String jsonString) {
  final json = jsonDecode(jsonString);
  if (json is! Map<String, dynamic>) {
    throw ArgumentD4rtException('Invalid AST JSON: expected object');
  }
  return SCompilationUnit.fromJson(json);
}