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: 5058D6B1.1070902@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2012-09-18 20:24:44 Re: JSON type caster
Previous Message Tobias Oberstein 2012-09-18 20:12:59 Re: JSON type caster