JSON and Firefox sessionstore.js

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Apr 22 23:31:23 EDT 2009


On Thu, 23 Apr 2009 05:08:35 +0100, I V wrote:

> For something with at least a vague air of credibility to it, somebody
> who appears to be a Mozilla developer comments on their bug tracker,
> that sessionstore.js isn't "pure JSON" (though he only identifies the
> parantheses, which are much easier to fix, as being a problem):
> 
> https://bugzilla.mozilla.org/show_bug.cgi?id=407110#c2

Ah, fantastic! Or rather, damn, I was hoping it was proper JSON and not 
some sort of bizarre mutant.

For what it's worth, removing the leading/trailing parentheses gives a 
different error:

>>> import io
>>> import json
>>> filename = '.mozilla/firefox/2z5po7dx.default/sessionstore.js'
>>> text = open(filename).read()
>>> text = io.StringIO(text[1:-1])
>>> x = json.load(text)
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 340, in raw_decode
    obj, end = next(self._scanner.iterscan(s, **kw))
  File "/usr/local/lib/python3.0/json/scanner.py", line 55, in iterscan
    rval, next_pos = action(m, context)
  File "/usr/local/lib/python3.0/json/decoder.py", line 175, in JSONObject
    raise ValueError(errmsg("Expecting property name", s, end))
ValueError: Expecting property name: line 1 column 1 (char 1)


Presumably that's the error you get when you don't quote your property 
names properly.



-- 
Steven



More information about the Python-list mailing list