![பயர்பாக்ஸ் logo](https://assets-prod.sumo.prod.webservices.mozgcp.net/media/uploads/products/2020-04-14-08-36-13-8dda6f.png)
Filter out start of JSON responses
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.
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?
All Replies (1)
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');})()