alternative way to do JSON.parse based on readystate