Add method to convert AST in valid JSON