Fixed issue #1366 about extra characters in returning JSON from server