我是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;
我得到的结果如下
“{” 类型 “:” 功能”, “几何”:{ “类型”: “的MultiPolygon”, “坐标”:[[[[979999.082000002,196493.280000001],[979897.966399997,196147.8204],[979718.105800003,196197.441599995] ,[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是一个文本值..请帮我这个。如果你能给我解决方案,这将是很好的......
提前致谢