2

I'm kind of confused and was hoping one of you could give me some clarity. I am trying to get the best performance out of my Ajax request. The data coming across the wire is a 1,000 row 10 column table. The debate is: should I send Json or should I send Text? If I send Json, then doesn't that mean I have to include the column name for each item? Basically, the total size of the request will be increased by 10 x 1,000 in text inside the Json. Or, I can send a CSV across the wire and exclude the column names, thereby significantly reducing the size of the transfer. This has its own performance implications though, because then I have to parse the CSV on the client, rather than having it ready to go in Json. Thoughts anyone? Thanks

3
  • You don't need the keys/column names for json output, why would you think you do? Have you tried testing both ways yet? Questions about performance are better backed by numbers. More context would help as well (what the data is, what it's used for, how it is structured, etc.) Commented Sep 11, 2013 at 3:23
  • If your data is simple enough, you could do CSV, but if you gzip, I don't know if it'll make much difference. You seem to think that JSON doesn't need to be parsed. You're going to be parsing either way. Commented Sep 11, 2013 at 3:24
  • So what exact problem are you solving? "Optimize something random" on the site? Commented Sep 11, 2013 at 3:25

1 Answer 1

2

What about just sending array of arrays inside JSON object like this and you won't have to parse CSV

{data: [ [a, a , a] , [ b, b, b] ] }
Sign up to request clarification or add additional context in comments.

3 Comments

If I send an array of arrays, then I cannot acces the items by their names. I need them to be accessible by obj.name
According to your question, I understood that CSV is an option however you don't want the parsing. In that case, my suggestion would be somehow better.
You can save index for columns something like.. var columns = { id:0, name:1, price:2 } And for each row, you get column by row[i][ columns.id ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.