Re: PATCH: Add hstore_to_json()

Ron Mayer <rm_pg@cheapcomplexdevices.com>

From: Ron Mayer <rm_pg@cheapcomplexdevices.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>, Robert Haas <robertmhaas@gmail.com>, "David E. Wheeler" <david@kineticode.com>, Peter Eisentraut <peter_e@gmx.net>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2009-12-18T21:11:52Z
Lists: pgsql-hackers
+1 for such a feature, simply to avoid the need of
writing a hstore-parser (which wasn't too bad
to write, but it felt unnecessary).   Doesn't
matter to me if it's hstore-to-json or hstore-to-xml
or hstore-to-yaml.  Just something that parsers are
readily available for.

Heck, I wouldn't mind if hstore moved to using any one
of those for it's external representations by default.

Tom Lane wrote:
> a ton of special syntax for xml support, ...a json type...
> [ I can already hear somebody insisting on a yaml type :-( ]

If these were CPAN-like installable modules, I'd hope
there would be eventually.  Don't most languages and
platforms have both YAML and JSON libraries?  Yaml's
user-defined types are an example of where this might
be useful eventually.

Tom Lane wrote:
> Well, actually, now that you mention it: how much of a json type would
> be duplicative of the xml stuff?  Would it be sufficient to provide
> json <-> xml converters and let the latter type do all the heavy lifting?

I imagine eventually a JSON type could validate fields using
JSON Schema.   But that's drifting away from hstore.

> (If so, this patch ought to be hstore_to_xml instead.)

Doesn't matter to me so long as it's any format with readily
available parsers.