Merge changes Id52f30a5,I8841de64

* changes:
  analyze_matrix: support json
  analyze_matrix: refactor to prepare for JSON output.