Home » Java » How do I parse Python Script(py) file into Java POJOs?-Exceptionshub

How do I parse Python Script(py) file into Java POJOs?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

My java code generates Python file from XML input. In order to validate this translation, I would like to go through Python output file and check its content. Right now I am just using String contains method but I think if I could parse Python code into Java POJO, that would make this testing easy. If you think, there is another way to perform this unit testing. Kindly suggest. Thanks in advance.

How to&Answers:

You can parse python code using antlr library. Via antlr you can build AST (Abstract Syntax Trees) and validate it