I am planning to send Javascript array object filled with data by encoding it in JSON. Any good jquery plugins for this ?
On Java end, what is the standard way of parsing the JSON into a Java array ?
Overall flow is like this:
- Javascript compiles bunch of data on current page and stores it in array.
- Array object encoded into JSON.
- Java code saves JSON.
- Repeat and Java code compiles succesive JSONs for each page.
- Java code submits one mega JSON to server.
Another problem I have is with 5. How would you go about submitting large JSON data to the server securely ?
On the client-side, if you support only modern browsers, you can use the native JSON.stringify() API. Otherwise, the json2.js library is fine.
On the server-side, there are a herd of libraries to have a look at:
I’m pointing you to Jackson first at it seems to be the fastest in many cases. However, I find its documentation harder to get my mind around every time I need to get back to it. Json-lib is sometimes easier to get to grasp with for smaller tasks that do not require top-speed, but with still completely acceptable results.
Gson as also a good reputation and is very flexible, however the previous benchmarks I came across seemed to indicate that it did not perform as well as Jackson. The newly released 1.5 version might have improved that, but I don’t know.
It comes down to the degree of flexibility you want, the performance you need, and whether you want a simple API or if you don’t mind a more complex one.
Regarding security, I think your best option here would be to support SSL for the connections. Otherwise you could just make things harder for eavesdroppers by simply using JS-based encryption, but that won’t protect you too much. Look for SJCL (Stanford Javascript Crypto Library) for this.