This is what you want:
var data="{"count" : 1, "stack" : "sometext\\n\\n"}";
You need to escape the \ in your string (turning it into a double-\), otherwise it will become a newline in the JSON source, not the JSON data.
This is what you want:
var data="{"count" : 1, "stack" : "sometext\\n\\n"}";
You need to escape the \ in your string (turning it into a double-\), otherwise it will become a newline in the JSON source, not the JSON data.