I am new to Mondrian. I am using it in my project for OLAP operations. I am testing it with Foodmart database. The problem is that I need the OLAP operations results in JSON format. I know that mondrian has the same structure as JSON in the form of hierarchies. I want to generate a JSON file as an output from the result of mondrian MDX query. The result should be similar to OLAP operations. I don't know how to iterate over the result generated from MDX query. Here is the code.
String connStr = "Provider=mondrian;" +
"Catalog=/WEB-INF/FoodMart.xml;" +
"JdbcDrivers=com.mysql.jdbc.Driver;" +
"Jdbc=jdbc:mysql://localhost/foodmart;" +
"jdbcUser=root;" +
"jdbcPassword=;";
String queryStr ="select {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].>Store Sales]} ON COLUMNS,"+"Crossjoin(Hierarchize(Union({[Promotion Media].[All Media]}, >[Promotion Media].[All Media].Children)), {[Product].[All Products]})
ON ROWS"+" from [Sales]"+"where [Time].[1997]";
Connection connection = DriverManager.getConnection(connStr, null);
Query query = connection.parseQuery(queryStr);
Result result = connection.execute(query);
result.print(new PrintWriter(System.out));
Actually I need to perform OLAP operations on data warehouse which is stored in MySQL. The resulted data should be in JSON format which I will pass to D3 http://mbostock.github.com/d3 for visualizations. For data format I have to use JSON format. Please any suggestions how to iterate MDX result and convert it in JSON file. I am using Pentaho Mondrian for this purpose. Thanks.