1
votes

I have to some simple data format conversion. From CSV to Json. I am wondering if doing this server side or client side will make any difference ?

My use case is : I have a CSV file at server, and I am reading one row every 20 milliseconds and want to convert it to Json before it gets to the client app. So shall I convert it into Json on server side and use something I found like Json Http request to get json format data at client side. Or shall I write a javascript method to convert text format response text to json.

please suggest. Thank You!

1
if your CSV file at server side then not useful to convert to Json on server side only. - Viral Shah
do parse your CSV over client through data.toJSON() and make ur CSV to JSON conversion logic over client side...that will increase your execution speed also.. - Viral Shah
Thanks a lot for response. But my concern is that tomorrow CSV may get replaced by something else .. (may be data coming on a tcp socket or so) in that case how easy will it be to do the required change if I parse csv data over client for now the way you suggested - Andy897
its pretty much easier if get replace CSV by any other technology if you do JSON logic over client side - Viral Shah

1 Answers

2
votes

I believe conversion logic should be done on server side. Make your client as simple and light as possible - it should get JSON from your server and simply display it via user interface. The conversion that you described is not a heavy but imagine: 1000 clients doing the same operation vs 1 server doing it and distributing to 1000 clients.

That said, if you are designing an API on server side, you should provide your data in rawest possible format. Your client servers then will have more flexibility on slicing/dicing and presenting the data for their simple UI clients.