@Palladi_N
dev

Как получить данные из json-колонки?

Мне нужно получить данные координат - "coordinate" для использования в цикле так же данные по ключам "fillOpacity", "fillColor" и ...
Это значение в ячейке таблицы
[[{"id":8420792,"coordinate":[{"lat":"50.480375","lng":"30.503879"},{"lat":"50.476547","lng":"30.49564"},{"lat":"50.472832","lng":"30.493236"},{"lat":"50.461687","lng":"30.49152"},{"lat":"50.45568","lng":"30.499588"},{"lat":"50.452401","lng":"30.511089"},{"lat":"50.456008","lng":"30.524135"},{"lat":"50.459177","lng":"30.527569"},{"lat":"50.46923","lng":"30.525337"},{"lat":"50.475021","lng":"30.519672"}],"polygon_formatting":{"fillColor":"#00ff00","fillOpacity":"1","strokeWeight":"1","strokeColor":"#ff0000","strokeOpacity":"1","clickable":true,"editable":true,"draggable":false,"zIndex":1,"id":8420792},"popygon_all_properties":{"redirectUrl":"","infoWindow":"Tnl6aG5paSBWYWw=","fillColor":"#dd9933","strokeColor":"#ff0000","strokeWeight":1,"strokeOpacity":"0.4","fillOpacity":"0.4"}}]]


Я делаю выборку из таблицы:
$coordinates = $wpdb->get_results( "SELECT ID, assignploygons FROM wp_wdap_collection" );
print_r($coordinates);

и получаю это
Array
(
    [0] => stdClass Object
        (
            [ID] => 1
            [assignploygons] => [[{"id":8420792,"coordinate":[{"lat":"50.480375","lng":"30.503879"},{"lat":"50.476547","lng":"30.49564"},{"lat":"50.472832","lng":"30.493236"},{"lat":"50.461687","lng":"30.49152"},{"lat":"50.45568","lng":"30.499588"},{"lat":"50.452401","lng":"30.511089"},{"lat":"50.456008","lng":"30.524135"},{"lat":"50.459177","lng":"30.527569"},{"lat":"50.46923","lng":"30.525337"},{"lat":"50.475021","lng":"30.519672"}],"polygon_formatting":{"fillColor":"#00ff00","fillOpacity":"1","strokeWeight":"1","strokeColor":"#ff0000","strokeOpacity":"1","clickable":true,"editable":true,"draggable":false,"zIndex":1,"id":8420792},"popygon_all_properties":{"redirectUrl":"","infoWindow":"Tnl6aG5paSBWYWw=","fillColor":"#dd9933","strokeColor":"#ff0000","strokeWeight":1,"strokeOpacity":"0.4","fillOpacity":"0.4"}}]]
        )

    [1] => stdClass Object
        (
            [ID] => 2
            [assignploygons] => [[{"id":6295770,"coordinate":[{"lat":"50.4927","lng":"30.390551"},{"lat":"50.499689","lng":"30.408919"},{"lat":"50.49685","lng":"30.432265"},{"lat":"50.490625","lng":"30.445998"},{"lat":"50.479594","lng":"30.448401"},{"lat":"50.468997","lng":"30.439303"},{"lat":"50.46408","lng":"30.407202"},{"lat":"50.462987","lng":"30.383513"},{"lat":"50.477518","lng":"30.384715"},{"lat":"50.488004","lng":"30.387976"}],"polygon_formatting":{"fillColor":"#ff0000","fillOpacity":"0.6","strokeWeight":"1","strokeColor":"#ff0000","strokeOpacity":"0.2","clickable":true,"editable":true,"draggable":false,"zIndex":1,"id":6295770},"popygon_all_properties":{"redirectUrl":"","infoWindow":"","fillColor":"#00ff00","strokeColor":"#ff0000","strokeWeight":1,"strokeOpacity":0.2,"fillOpacity":0.6}}]]
        )

)


Как мне получить те данные по ключам что мне нужны, для построения цикла координат и так же просто значения "fillOpacity", "fillColor" и ....?
  • Вопрос задан
  • 67 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Vitsliputsli
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы