Saturday, 7 September 2013

jQuery.parseJSON returns null

jQuery.parseJSON returns null

I am passing valid JSON on the server side (using node.js) but not able to
parse on the client side (using JQuery). jQuery.parseJSON returns null .
Any assistance will be much appreciated.
Server side-
var message = [{key:"1", count:1},{key:"2", count:2}];
client.publish('update', JSON.stringify(message));
Client side -
socket.on("update", function(data) {
var obj = jQuery.parseJSON(data);
alert (obj); // returns null
// do something
}

No comments:

Post a Comment