[Mondrian] Mondrian output as a JSON file

Pedro Alves pmgalves at gmail.com
Fri Mar 9 12:10:34 EST 2012


I don't know your use case, but take a look at CDA (cda.webdetails.org). 
It outputs in several formats, including json


-pedro




On 03/09/2012 05:55 AM, Shehzad Ahmad Hashmi wrote:
> 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));
>
>
>
>
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian


More information about the Mondrian mailing list