прошу помочь, как "распарсить" json до координат? Не могу сообразить, как тут использовать json_array_elements
with w as (
select '{"type" : "FeatureCollection", "features" : [{"type": "Feature", "geometry": {"type":"Polygon","coordinates":[[[52.0967564,59.4503427],[52.2689509,59.416844],[52.442522,59.383044],[52.6673693,59.4035124],[52.5773728,59.4228868],[52.5796804,59.4287556],[52.4305758,59.4661864],[52.4478745,59.5075522],[52.3150655,59.5344411],[52.1945329,59.5202917],[52.0967564,59.4503427]]]}, "properties": {"osm_id": -3790402, "admin_level": 8, "parents": "-382779,-115100,-1075831,-60189", "name": "Светлополянское городское поселение", "local_name": "Светлополянское городское поселение", "name_en": null}}]}'::jsonb as j
)
SELECT
j -> 'features' -> 'properties' ::TEXT,
j -> 'features' -> 'properties' -> 'name'::TEXT,
j -> 'features' -> 'properties' -> 'local_name'::TEXT,
j -> 'features' -> 'properties' -> 'admin_level'::TEXT
FROM w;
так попробуй
with w as (
select '{"type" : "FeatureCollection", "features" : [{"type": "Feature", "geometry": {"type":"Polygon","coordinates":[[[52.0967564,59.4503427],[52.2689509,59.416844],[52.442522,59.383044],[52.6673693,59.4035124],[52.5773728,59.4228868],[52.5796804,59.4287556],[52.4305758,59.4661864],[52.4478745,59.5075522],[52.3150655,59.5344411],[52.1945329,59.5202917],[52.0967564,59.4503427]]]}, "properties": {"osm_id": -3790402, "admin_level": 8, "parents": "-382779,-115100,-1075831,-60189", "name": "Светлополянское городское поселение", "local_name": "Светлополянское городское поселение", "name_en": null}}]}'::jsonb as j
)
SELECT
f -> 'properties',
f -> 'properties' ->> 'name',
f -> 'properties' ->> 'local_name',
f -> 'properties' ->> 'admin_level'
FROM w, jsonb_array_elements(w->'features') f;