[postgis-tickets] [PostGIS] #3687: Add casts for (geometry, geography) -> (json, jsonb)
PostGIS
trac at osgeo.org
Mon Jan 16 16:08:49 PST 2017
#3687: Add casts for (geometry, geography) -> (json, jsonb)
--------------------------+---------------------------
Reporter: dbaston | Owner: dbaston
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 2.4.0
Component: postgis | Version: trunk
Resolution: | Keywords:
--------------------------+---------------------------
Comment (by dbaston):
Yes, row_to_json and to_json/to_jsonb pick it up, at least in the 9.6 that
I'm running. The cast doesn't event have to be declared IMPLICIT,
apparently.
{{{
WITH TEST AS
(SELECT 1::int AS id, st_makepoint(random(), random()) as geom)
SELECT row_to_json(q) FROM (SELECT * from test) q;
}}}
In the 9.5 docs:
Returns the value as json or jsonb. Arrays and composites are converted
(recursively) to arrays and objects; otherwise, **if there is a cast from
the type to json, the cast function will be used to perform the
conversion**; otherwise, a scalar value is produced. For any scalar type
other than a number, a Boolean, or a null value, the text representation
will be used, in such a fashion that it is a valid json or jsonb value.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3687#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list