JSON encode/decode objects automagically

This allows us to set and get objects from the localStorage shim seamlessly.
Test whether it is already a string. If it is not a string, then try to stringify it. This covers all cases of string-serializeable types.