JSON and Firefox sessionstore.js

MRAB google at mrabarnett.plus.com
Wed Apr 22 20:43:59 EDT 2009


Steven D'Aprano wrote:
> Unless I'm badly mistaken, the Firefox sessionstore.js file is supposed 
> to be JSON.
> 
> In Python 3.0, I do this:
> 
>>>> import json
>>>> filename = '.mozilla/firefox/2z5po7dx.default/sessionstore.js'
>>>> json.load(open(filename))
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.0/json/decoder.py", line 340, in raw_decode
>     obj, end = next(self._scanner.iterscan(s, **kw))
> StopIteration
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python3.0/json/__init__.py", line 267, in load
>     parse_constant=parse_constant, **kw)
>   File "/usr/local/lib/python3.0/json/__init__.py", line 307, in loads
>     return _default_decoder.decode(s)
>   File "/usr/local/lib/python3.0/json/decoder.py", line 323, in decode
>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>   File "/usr/local/lib/python3.0/json/decoder.py", line 342, in raw_decode
>     raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded
> 
> 
> Am I doing something wrong? Am I mistaken about sessionstore.js being 
> JSON? Is there a bug in json?
> 
> If it matters, I'm using Firefox 2.0.0.5 under Linux.
> 
> 
As far as I'm aware, the ".js" extension indicates a JavaScript file.

Is there a specific extension for JSON?

[Checks Google...]

Ah, the extension for JSON is ".json". Makes sense! :-)



More information about the Python-list mailing list