Question

I have a grails controller to render json files as follows, to be further used by d3 on my front end (.gsp file):

def dataSource
def salesjson = {
    def sql = new Sql(dataSource)
    def rows = sql.rows("select date_hour,mv,device,department,browser,platform,total_revenue as metric, total_revenue_ly as metric_ly from composite")
    sql.close()        
    render rows as JSON
}

I use this file to render my crossfiltered dc-charts on the front end. The problem is, queries such as the one above returns large JSON file / object and my client stops working and hangs. (100MB plus, on the client side, and still loading!!)

I can't think of any alternative to this method, which would reduce my file size (maybe rendering as a csv string? Would that help a lot? If so, how do I go about it? I have about 600,000 rows in my json currently)

What other options do I have?

Était-ce utile?

La solution

I'd suggest using something like MessagePack to create more binary like smaller representations of your JSON. There are a few other options out there, but I think this one is probably the most JVM / Javascript friendly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top