Open mche opened 7 years ago
Yes, it's been on our long-term todo for a while. Not sure when people will have tuits for this: it's a non-trivial task.
@turnstep are you thinking of rolling-your-own serialization/deserialization, or just hooking into JSON::XS
or similar?
We need to do our own parsing regardless, in the same way the arrays are done now. Whether or how to involve JSON::XS is somewhat secondary at the moment.
JSON is probably the most important type for automatic conversion in DBD::Pg, but not the only one. In some cases users may want to convert NUMERICSs to Math::BigInt or Math::BigFloat; dates/times and composite types also may be converted to something etc.
Do the thing I am thinking about is to allow custom conversion for the data types. A user may be given a possibility to specify converters for the data types (like TRANSFORMS in stored procedures). Something like $dbi->set_transform('jsonb', \&JSON::XS::encode_json,\&JSON::XS::decode_json) This would be a flexible universal solution.
That sounds nice in theory, but I'm not sure how that would work in practice. The conversions happen in the Perl XS code, and involve low-level transformations of textual representations of certain types to Perl objects.
Not sure when people will have tuits for this: it's a non-trivial task.
What areas does the complexity reside in?
Hi!
Let me stupid question. Do you have planned to autoJSONify from Perl data to PG json/jsonb data types and backwards?
Regards.