Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Filter out start of JSON responses

  • 1 reply
  • 1 has this problem
  • 4 views
  • Last reply by cor-el

more options

I sometimes use firefox to view data from APIs, however many private APIs include strings, usually `while(1);`, at the start of the JSON response for security reasons.

See this link as to why

Is there a way to get firefox to filter out these strings, so it can parse the json?

I sometimes use firefox to view data from APIs, however many private APIs include strings, usually `while(1);`, at the start of the JSON response for security reasons. [https://stackoverflow.com/questions/2669690/why-does-google-prepend-while1-to-their-json-responses See this link as to why] Is there a way to get firefox to filter out these strings, so it can parse the json?
Attached screenshots

All Replies (1)

more options

You can possibly use a JavaScript bookmarklet to clean up the code if you have loaded the JSON response in a tab. Valid JSON usually starts with a '{' or a '[' and you can strip off leading characters. You may have to refine the code if it isn't working in special cases as I do not have examples to test it.

javascript:(function(){var t=document.querySelector('body>pre');t.textContent=t.textContent.replace(/^([^\[{])*(.*)/,'$2');})()