Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much JSON is too much JSON?

I am developing a bookmark site like delicious. In order to provide a better and a faster user experience to the user, i am grabbing all the bookmarks from the db table and form a json object with all the bookmark information in it. Eg, for each bookmark, i have an id, title, url, description, tags etc. The json object is already formed on the first page load. I then get the output json, use jquery.each to style and inject relevant html on the fly.

Right now, i have no option to test it so here comes my question: imagining there is no limits on the number of bookmarks a user can save, what would be the effect on this structure on the browser (or any other problems that might arise for this situation) if a user has, say, 2000 bookmarks also considering that paging is not an option for this particular project.

like image 236
Subliminal Hash Avatar asked Sep 18 '11 19:09

Subliminal Hash


People also ask

Is there a limit to JSON size?

The maximum length of JSON strings. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data. JSON itself has no inherent limit.

How much does JSON compress?

5. Shorter Field Names in JSON. Using single-character field names leads to data that is 72.5% of the original size. Moreover, using gzip will compress that to 23.8%.

What is big JSON?

A stream based implementation of JSON.parse and JSON.stringify for big POJOs. There exist many stream based implementations of JSON parsing or stringifying for large data sets.

What are the disadvantages of JSON?

JSON isn't as robust a data structure as XML is. There is no ability to add comments or attribute tags to JSON, which limits your ability to annotate your data structures or add useful metadata. The lack of standardized schemas limits your ability to programmatically verify that your data is correct.


1 Answers

Probably controversial but anyway. How can paging not be an option? When is it ever relevant to show 2k bookmarks at a time? I'd say never.

When you're returning that much data (of course it depends on how much text) you're wide open to DDOS attacks. Imagine an attacker that gets hold of a url containing several megabytes of json, it would not be that hard to sink your servers.

It would be nice with some more information on your UI so we can analyze what data you really need.

like image 110
alexn Avatar answered Oct 10 '22 04:10

alexn