[Mondrian] Mondrian output as a JSON file

Shehzad Ahmad Hashmi s.hashmi44 at gmail.com
Fri Mar 9 00:55:35 EST 2012


Hi!
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 parse the result
generated from MDX query. Please help me as I have to use it in my FYP.
Thanks.
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));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20120309/e5fff868/attachment.html 


More information about the Mondrian mailing list