epitka
epitka

Reputation: 17637

JSON, compressing it on client and server side

Anybody knows of any utility that will compress JSON server side (C#), and re-constitute it into JSON on the client side and vice versa. My whole page view model is in json, and need to find a way to reduce size of it. I found cJSON, and RISON, but I don't see C# implementations.

Any ideas?

Clarification: On server side, I need to take a JSON string and register client side variable that is encoded/compressed to reduce the size. On the client side I need a utility that I can call from JavaScript to decode/uncompress it. Also need this in reverse order too.

Reference links:

cJson http://stevehanov.ca/blog/index.php?id=104

Rison http://mjtemplate.org/examples/rison.html

Upvotes: 1

Views: 2889

Answers (2)

Dave Ward
Dave Ward

Reputation: 60580

I'd second Llyod's answer and also add that you're not considering the client-side decompression overhead.

Deflate and gzip are worthwhile largely because browsers handle decompression in native code. If you implement a custom JSON compression scheme, you'll have to decompress it using JavaScript, which will be significantly slower. Unless you're doing that in a browser that supports Web Workers (i.e no versions of IE), that really isn't viable. Either way, the JavaScript-based decompression would almost certainly add more latency than the compression would save.

Upvotes: 1

Lloyd
Lloyd

Reputation: 29668

Why not use HTTP compression and allow the browser/web server to handle the compression of the requests?

Upvotes: 4

Related Questions