Skip site navigation (1) Skip section navigation (2)

Re: JSON type caster

From: Tobias Oberstein <tobias(dot)oberstein(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: JSON type caster
Date: 2012-09-18 20:16:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: psycopg
>>        #o = json.loads(value)
>>        o = simplejson.loads(value, use_decimal = True)
> I think this should be dependent on the Python version and use either
> the builtin module or simplejson where not available. The loads
> function should be probably exposed to the customer for better
> customization of the result. So, all in all, I think psycopg should

Yes, absolutely right. To allow serialization of decimal, datetime and 
even custom classes ..

>>        return o
>>     except:
>>        raise InterfaceError("bad JSON representation: %r" % value)
> Probably should be DataError. Not sure it is the case to dump the
> entire value into the exception: it may be huge.

I agree. Default should be no dumping. I guess it's a very unlikey
case anyway, since when PG is handling it as JSON, it _is_ probably
a JSON ..

In response to

psycopg by date

Next:From: Daniele VarrazzoDate: 2012-09-18 20:24:44
Subject: Re: JSON type caster
Previous:From: Tobias ObersteinDate: 2012-09-18 20:12:59
Subject: Re: JSON type caster

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group