Yes, you can without a problem. No manual encoding / decoding required!
Your code will look like this:
var jsonParam = '{"name":"Edgar"}'; //Sample json param $.ajax({ ... type: "get", //This sends in url data: {jsonParam: jsonParam}, //This will encode your json for url automatically dataType: "json", //With this the response will be automatically json-decoded! success: function(response){ //Assuming your server output was '{"lastName":"Villegas"}' as string alert(response.lastName); } });
As you can see, manual encoding / decoding is not required. JQuery handles all this!
Hope this helps. Greetings
PS: If for some reason you need to encode / decode json manually to use javascript encodeURIComponent(string) and $.parseJSON(jsonString) methods in JavaScript.
source share