Chrome Extension Development: Illegal Access related to JSON and localStorage

by Stephen Fluin 2010.04.22

While developing my CSS Destyler, I came across an error in my console stating "Illegal Access", the relevant line looked as follows:


After some initial exploration, I determined that the issue was not related to the access of the localStorage, as "illegal access" would make me think. Instead it was related to the JSON parse statement.

For some reason, JSON errors with "illegal access" whenever you try to parse a null. The solution was to ensure that the item passed into JSON.parse was not null.