Question: I am trying to add Java memory profiling into my devops pipeline. I am using Eclipse MAT command line script for this purpose. Once I provide the hprof file as input to this and it generates suspect report. I need to parse this HTML report and make decision based on this.
This is cumbersome and also the parsing is not structured. I want either XML/JSON report or I want to see how the actual report is generated by Eclipse MAT. If I found that I can get the code and customize based on my need. Any suggestions on this.

Answer: 
Eclipse Memory Analyzer is open source, and all the code is here: <https://git.eclipse.org/c/mat/org.eclipse.mat.git>

The leak suspects code is in
<https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java>
and
<https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java>

The leak suspects report is clean HTML which passes HTML validation, which would aid parsing.

Your request for a XML/JSON report is a reasonable one, but is not currently provided by MAT. There is provision for one to be added, using the rendering extension point <http://help.eclipse.org/latest/topic/org.eclipse.mat.ui.help/doc/org_eclipse_mat_report_renderer.html> . There are already HTML, CSV and TXT renderers and so a JSON extension point could be added. There are then design decisions to be made about how to represent trees and tables in JSON, and how to convert HTML from say the yellow boxes of the leak suspects report to JSON.

As I know of other people who want a JSON formatted report it may be worthwhile following it up more formally with the MAT community, either on the forum <https://www.eclipse.org/forums/index.php?t=thread&frm_id=186> or on Bugzilla or on the developer mailing list if you are proposing to help write code.
Another option is to implement your own extension: <https://wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer#Calling_One_Query_from_Another> and call the `leak_hunter` query. Then read through the details of the `IResult` and transform those to a json object.