Why does Google prefix its (private) JSON answers with while(1);?
For example, here’s a response from Google Calendar when turning a calendar on and off:
while (1); [ ['u', [ ['smsSentFlag', 'false'], ['hideInvitations', 'false'], ['remindOnRespondedEventsOnly', 'false'], ['hideInvitations_remindOnRespondedEventsOnly', 'true_false'], ['Calendar ID stripped for privacy', 'true'], ['smsVerifiedFlag', 'true'] ]] ]
I’m guessing this is to prevent people from running an eval() on it, but all you really need to do is change the while and you’re good to go. I’d guess the eval prohibition is to ensure that people create safe JSON parsing programmes.
I’ve seen this utilised in a few of other places, but Google uses it a lot more (Mail, Calendar, Contacts, etc.) Surprisingly, This Document begins with &&&START&&&, whereas Google Contacts appears to begin with while(1); &&&START&&&.
What exactly is going on here?