views:

36

answers:

1

Hi I have Jquery & ASP.NET server side. I am looking for a way to safely post data from a client to the server and vise versa without worrying of special characters like ",'~ etc... Is JSON a better way?

Thanks

A: 

Whatever you choose will need to be encoded for transport. If you just put the data into the URL, you should URL encode the data, if you put in JSON, you still need to escape " if the data is in a string.

Lou Franco
How can I encode the JSON using JS/Jquery?
oshafran
@oshafran: so far I know the only character you need to encode is the quote and you could do it like this \' (using the backslash)
Claudio Redi
So just do replace ' to \' before sending? what about Decoding it in the C# side?
oshafran
If you use a JSON parser, the string should be decoded for you already. If you are writing a JSON parser, you need to do it.
Lou Franco