I'm probably misinterpreting the question here, but...

On Dec 13, 2006, at 7:36 AM, Daniel O'Connor wrote:
> but the json used by exhibit is a bit more sane:
>
> {items:[{id:1,label:"Daniel",imageURL:"http:\/\/images.google.com.au 
> \/images?q=tbn:7-rLOervtN554M:http:\/\/www.advancedaquarist.com\/ 
> 2005\/7\/fish_album\/AA2.jpg",age:18}]}

If this came from exhibit, exhibit appears to be emitting invalid  
json. Here's Bob Ippolito's simplejson trying to chew on it:

--

Python 2.4.2 (#2, Mar 13 2006, 13:08:19)
[GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import simplejson
 >>> json = """{items:[{id:1,label:"Daniel",imageURL:"http:\/\/ 
images.google.com.au\/images?q=tbn:7-rLOervtN554M:http:\/\/ 
www.advancedaquarist.com\/2005\/7\/fish_album\/AA2.jpg",age:18}]}"""
 >>> decoded = simplejson.loads(json)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/home/ed/python/lib/python2.4/site-packages/simplejson/ 
__init__.py", line 209, in loads
     return cls(encoding=encoding, **kw).decode(s)
   File "/home/ed/python/lib/python2.4/site-packages/simplejson/ 
decoder.py", line 251, in decode
     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   File "/home/ed/python/lib/python2.4/site-packages/simplejson/ 
decoder.py", line 268, in raw_decode
     obj, end = self._scanner.iterscan(s, **kw).next()
   File "/home/ed/python/lib/python2.4/site-packages/simplejson/ 
scanner.py", line 50, in iterscan
     rval, next_pos = action(m, context)
   File "/home/ed/python/lib/python2.4/site-packages/simplejson/ 
decoder.py", line 127, in JSONObject
     raise ValueError(errmsg("Expecting property name", s, end))
ValueError: Expecting property name: line 1 column 1 (char 1)
 >>>

--

Don't the keys need to be quoted? And why are forward slashes escaped  
with backslashes inside strings?

--

 >>> json = """{"items":[{"id":1,"label":"Daniel","imageURL":"http:// 
images.google.com.au/images?q=tbn:7-rLOervtN554M:http:// 
www.advancedaquarist.com/2005/7/fish_album/AA2.jpg","age":18}]}"""
 >>> decoded = simplejson.loads(json)
 >>> print decoded
{u'items': [{u'age': 18, u'imageURL': u'http://images.google.com.au/ 
images?q=tbn:7-rLOervtN554M:http://www.advancedaquarist.com/2005/7/ 
fish_album/AA2.jpg', u'id': 1, u'label': u'Daniel'}]}

--

//Ed

[1] http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.3/docs/ 
index.html
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general

Reply via email to