简体   繁体   中英

Converting to geojson from db values in PostgreSQL

I am new to postgreSQL.In my project i have a table and i need to make all field as a json format. I tried below code

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;

I got result like below

"{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[979999.082000002,196493.280000001],[979897.966399997,196147.8204],[979718.105800003,196197.441599995],[979823.056799993,196549.6884],[979999.082000002,196493.280000001]]]]},"properties": (...)"

Just look the result. Inside properties it shows some ... only.. Please help me to get the values inside the property. Desired output looks like below

>   {    "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'    } }

In my case object id is a text value.. Please help me for this. This will be great if u can give me the solution...

Thanks in advance

If you are saying that the output includes the (...) instead of listing your properties, that is a side effect of whatever GUI you are using to run the query. pgAdmin for example will only show you so much output before adding the (...) .

在此处输入图片说明

Double clicking on the field (...) will open a dialog box that shows the entire query result and will allow you to copy it all.

在此处输入图片说明

Thanks one again for your answer @Leonardo Alves and @D T. I found one more option for the same. 在此处输入图片说明

execute and save the result will give complete output values instead of dots.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM