Gaurav
Gaurav

Reputation: 2103

Which is better option JSON? or CSV? (for large data (~1 GB) from remote server to (frontend of) web application

I am trying to fetch large tabular data from a remote url which send data in binary format. To read this data I am using a C program that runs (inbuilt) with server. The C program fetches fetches data in binary format from various sources, convert into readable form and send it to frontend.

The I have two option:

  1. I convert the data into CSV format which is lighter or
  2. I convert the data into JSON format which is little heavier but easy to interpret by frontend web application

I want to to operations like sorting and grouping of data in frontend. So can you suggest me which is better option to use in this scenario.

Updates:
1 -> frontend will just receive the data and may do sorting or grouping

Upvotes: 2

Views: 1889

Answers (1)

SteveP
SteveP

Reputation: 19093

If you must send all the data to the front end, you could use a json array to wrap each row. This minimises the amount of extra data you are adding e.g.

data:{
     columns:["A","B","C"],
     rows:[  [1,2,3],[4,5,6],[7,8,9]   ]
}

However, I would try to avoid sending all the data to the fronend application if possible. It should be possible to show pages of data by fetching the required data on demand using ajax calls. The server can do the heavy work of sorting, grouping etc. Consider storing the data in a database.

Upvotes: 3

Related Questions