I'm using the Goo.gl URL shortener to shorten links. I sed it a Json string and it return results like this which gets stored in xmlHttp.response:
"{
"kind": "urlshortener#url",
"id": "http://goo.gl/mR2d",
"longUrl": "http://google.com/"
}"
After sending the code, I try to parse it using JSON:
xmlHttp.send(jsonStr);
var short_url = JSON.parse(xmlHttp.response).id ;
When this code runs in a function, I get the following "Unexpected end of input" error:
getShortURL("http://google.com");
SyntaxError: Unexpected end of input
arguments: Array[0]
get message: function () { [native code] }
get stack: function () { [native code] }
set message: function () { [native code] }
set stack: function () { [native code] }
type: "unexpected_eos"
__proto__: Error
I had thought there may be some issue with the quotes in the string. What would be a good way to fix the problem?