简体   繁体   中英

how to convert an array of geojson which is a string back to geojson object

i have the following string, it is composed of two elements. in angular, i receive it as string. i want to convert the entire array/object to object.

tr = '[{'type': 'Polygon', 'coordinates': [[[6.692079221624859, 51.132973676729755], [6.692083695415655, 51.13288397493344], [6.692226264428672, 51.132886789666365], [6.6922217909136394, 51.13297649147165], [6.692079221624859, 51.132973676729755]]]}, {'type': 'Polygon', 'coordinates': [[[6.6923643602254, 51.13297930603986], [6.692368833464666, 51.13288960422561], [6.692511402523637, 51.132892418611185], [6.692506929560137, 51.132982120434384], [6.6923643602254, 51.13297930603986]]]}]'
    

how can i convert an array of geojson which is a string back to geojson object

If you get the object as a string, you can use JSON.parse(value) to parse it back to the expected array format.

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