Skip to content

Idea for smaller JSON #187

@hyanwong

Description

@hyanwong

Instead of storing each column name in the JSON file, why don't we store the column names as accessors to the index. I.e. instead of this:

{"data":
  {"nodes": [
    {"size":150,"symbol":"d3.symbolSquare","fill":"#1eebb1","stroke":"#053e4e","stroke_width":4,"id":0,"flags":1,"time":0,"child_of":[21],"parent_of":[],"x_pos_reference":-1,"label":"0","fx":100,"fy":450,"y":450,"index":0,"x":100,"vy":0,"vx":0},
    {"size":150,"symbol":"d3.symbolSquare","fill":"#1eebb1","stroke":"#053e4e","stroke_width":4,"id":1,"flags":1,"time":0,"child_of":[10],"parent_of":[],"x_pos_reference":-1,"label":"1","fx":161,"fy":450,"y":450,"index":1,"x":161,"vy":0,"vx":0},
    ...
    ], ...
}

we could use

{"colnames":{
    "nodes":{"size":0,"symbol":1,"fill":2,"stroke":3,"stroke_width":4,"id":5,"flags":6,"time":7,"child_of":8,"parent_of":9,"x_pos_reference":10,"label":11,"fx":12,"fy":13,"y":15,"index":16,"x":17,"vy":18,"vx":19}
},
"data":
    "nodes": [
    [150,"d3.symbolSquare","#1eebb1","#053e4e",4,0,1,0,[21],[],-1,"0",100,450,450,0,100,0,0},
    [150,"d3.symbolSquare","#1eebb1","#053e4e",4,1,1,0,[10],[],-1,"1",161,450,450,1,161,0,0},
    ...
    ], ...
}

Then the access would be

var nodecols=colnames.nodes
sz = data.nodes[0][nodecols.size]  // was sz = data.nodes[0].size

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions