Page 1 of 1

JSON and NODE

Posted: Fri Sep 14, 2012 7:36 pm
by hallsofvallhalla
So I know need to add several arrays to my map system and transfer them through Node. I want to make this as small as a footprint as possible. It will be around 10 arrays with the size of 144. I am not that familiar with JSON but would it be the best choice for transferring this info? Will it reduce the size significantly?

Re: JSON and NODE

Posted: Fri Sep 14, 2012 10:34 pm
by Jackolantern
JSON is not really designed to shrink your dataset, but rather, to make it easy to work with (particularly in Javascript since they are native JS objects). JSON was largely a response to the horrid bother of dealing with XML data in the early-to-mid 2000's.

If you have that much data, you would likely be better off with a custom, compressed protocol. Provided you can write the code to pack it on the server side and the code to unpack it on the client-side, it can be as tight as you want. For example, you could even have something that looks like this:

Code: Select all

"[ajD342sasDFg;aA35iDiap@;p51z5OHH9a;]"
...where each symbol represents a map point type and the semi-colons are some kind of delimiter. Of course I have no idea if that specific format would be helpful, since only you would know a way to represent it.

JSON is simply a way of representing data, but it is not a byte-efficient way of storing it for certain usages (for strings it is actually quite efficient, but games don't typically need whole, unique strings to represent map data).

Re: JSON and NODE

Posted: Fri Sep 14, 2012 11:19 pm
by jwalton922
You can come up with your own compression algorithm or use gzip or other compression technologies. Node .6 or higher has it built in I believe. I have not done it myself, but a google search should help you figure out how to do it.

This link was for a library that is no longer needed I believe: http://me.dt.in.th/page/NodeJS-express-gzip . Make sure you read the June update at the top if you look at the link (That's where I read it was built into Node).

Re: JSON and NODE

Posted: Sat Sep 15, 2012 1:58 pm
by hallsofvallhalla
interesting info here thanks. I assumed JSON shrunk the data but actually never questioned how. I already have a compressed version of the data coming across. I basically use a simple array of numbers to represent the map much like Impact works. The entire map with data is around 200 bytes.

Re: JSON and NODE

Posted: Sat Sep 15, 2012 4:04 pm
by Jackolantern
200 bytes per MUD movement doesn't sound bad at all 8-)

Re: JSON and NODE

Posted: Sun Sep 16, 2012 3:15 pm
by hallsofvallhalla
kewl. I was hoping it would be good. I may have to stretch that but I figure 1 character = about a byte so I just got to keep it low. I want to do a stress test soon. Might get it up and going with the chat system then have everyone test it.