-1

我有一组坐标需要采用 Geojson 格式但没有双引号,我也仅限于在此数据集上进行选择。这行代码

json_extract_array(st_asgeojson(st_makeline( array_agg(st_geogpoint(locs.lon, locs.lat) order by locs.date))),'$.coordinates') as geo

给我这个

[
  "[-8.6359,40.6371716666667]",
  "[-8.63589166666667,40.637165]", 
  "[-8.63589333333333,40.6371583333333]", 
  "[-8.63589,40.637165]", 
  "[-8.63588833333333,40.6371716666667]", 
  "[-8.635885,40.6371766666667]", 
  "[-8.63588166666667,40.63718]"
]

我需要它变成这样

[
  [-8.6359,40.6371716666667],
  [-8.63589166666667,40.637165],
  [-8.63589333333333,40.6371583333333],
  [-8.63589,40.637165],
  [-8.63588833333333,40.6371716666667],
  [-8.635885,40.6371766666667],
  [-8.63588166666667,40.63718]
]
4

1 回答 1

1

好的,我找到了答案,以防其他人有同样的问题。使用 json_extract 而不是 json_array_extract。这将删除双引号

json_extract(st_asgeojson(st_makeline( array_agg(st_geogpoint(locs.lon, locs.lat) order by locs.date))),'$.coordinates') as geo
于 2021-07-30T19:49:26.363 回答