简体   繁体   English

如何将字符串的 geojson 数组转换回 geojson object

[英]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.在 angular 中,我收到它作为字符串。 i want to convert the entire array/object to object.我想将整个数组/对象转换为 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我如何将一个 geojson 数组(一个字符串)转换回 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.如果将 object 作为字符串获取,则可以使用JSON.parse(value)将其解析回预期的数组格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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