Khoyendra Pande Khoyendra Pande - 5 months ago 8x
Javascript Question

Javascript to read json which is starting with some extra string

I'm trying to read a json url but JSON appearing some extra string before JSON start

JSON script is like:

throw 'allowIllegalResourceCall is false.';
"streetAddress":"88 8nd Street",
"city":"New York"
"number":"111 111-1111"
"number":"222 222-2222"

I'm trying to read this JSON using this below javascript:

$(document).ready(function() {
var ur= "http://json_url";

Is there any way to read this types of Json using java script/jQuery or ajax.


read this in some api doc

JSON Security String

GET requests are protected by including a security string on the line before the JSON text. The string generally looks like "throw 'allowIllegalResourceCall is false.';". To strip out this string, a regular expression should be used. For example, in python one could use:

json = re.sub(r"^throw.*;\s*","",json)

so you just need to replace the string with "" and use slashes around the regExp.


source :