【发布时间】:2017-11-17 15:02:52
【问题描述】:
我是 postgreSQL 的新手。在我的项目中,我有一个表,我需要将所有字段设置为 json 格式。我试过下面的代码
SELECT row_to_json(f) As feature
FROM (SELECT 'Feature' As type
, ST_AsGeoJSON(geom)::json As geometry
, row_to_json((SELECT l FROM (SELECT objectid) As l)) As properties
FROM plutoreferencedata As l WHERE l.objectid = '3') As f;
我得到如下结果
"{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[979999.082000002,196493.280000001],[979897.966399997,196147.8204],[979718.105800003,996] ,[979823.056799993,196549.6884],[979999.082000002,196493.280000001]]]]},"属性": (...)"
只看结果。在属性内部它只显示一些......请帮助我获取属性内的值。所需的输出如下所示
> { "geometry":{
> "type":"MultiPolygon",
> "coordinates":[
> [
> [
> [
> -309443.24253826,
> 388111.579584133
> ],
> [
> -134666.391073443,
> 239616.414560895
> ],
> [
> -308616.222736376,
> 238788.813082666
> ],
> [
> -309443.24253826,
> 388111.579584133
> ]
> ]
> ]
> ] }, "type":"Feature", "properties":{
> "objectid":'3' } }
在我的情况下,对象 id 是一个文本值。请帮助我。如果你能给我解决方案,那就太好了……
提前致谢
【问题讨论】:
标签: sql postgresql postgis geojson