span8
span4
你好,
我有一个Geojson文件。我想在properties中创建一个新的键-值对。
对象的当前属性看起来像它。
{"properties": {"name": "Seattle", "type": "CITY", "template": " ", "id": 1, "TRANDESCRI": "MAJOR TRANSIT ROUTE", "SLOPE_PCT": 1, "PVMTCATEGO": "ART", "PARKBOULEV": "N", "SHAPE_Leng": 666.1146823345148, "_related_candidates": "0"
我想在属性中创建一个新的键叫做description它应该有其他的键值对。它应该是这样的
{“属性”:{“名称”:“西雅图”,“类型”:“城市”,“模板”:“禁止”,“id”:1,“TRANDESCRI”:“主要交通路线”,“SLOPE_PCT”:1,“PVMTCATEGO”:“艺术”,“PARKBOULEV”:“N”,“SHAPE_Leng”:666.1146823345148,“_related_candidates”:“0”,“类型”:“城市”,“模板”:“禁止”,“id”:1}}
或者(描述在这里是一个列表)
{“属性”:{“名称”:“西雅图”,“类型”:“城市”,“模板”:“禁止”,“id”:1,“TRANDESCRI”:“主要交通路线”,“SLOPE_PCT”:1,“PVMTCATEGO”:“艺术”,“PARKBOULEV”:“N”,“SHAPE_Leng”:666.1146823345148,“_related_candidates”:“0”,“类型”:“城市”,“模板”:“禁止”,“id”:1}}
提前谢谢。
嗨@jugoslaviaa,文本类似于JSON文档。我认为一些JSON转换器可以帮助您从文本中提取所需的元素。
最后应该从中创建什么字符串?
我的文件的geojson格式和属性是这样的
{"properties": {"name": "Seattle", "type": "CITY", "template": " ", "id": 1, "TRANDESCRI": "MAJOR TRANSIT ROUTE", "SLOPE_PCT": 1, "PVMTCATEGO": "ART", "PARKBOULEV": "N", "SHAPE_Leng": 666.1146823345148, "_related_candidates": "0"
我想要生成新键描述哪个是已经在属性中的其他键和值的列表
{“属性”:{“名称”:“西雅图”,“类型”:“城市”,“模板”:“禁止”,“id”:1,“TRANDESCRI”:“主要交通路线”,“SLOPE_PCT”:1,“PVMTCATEGO”:“艺术”,“PARKBOULEV”:“N”,“SHAPE_Leng”:666.1146823345148,“_related_candidates”:“0”,“类型”:“城市”,“模板”:“禁止”,“id”:1}}
一种基本方法是使用jsonflatr提取所有成员作为特性属性并公开它们的名称,然后使用JSONTemplater重新构造所需的JSON文档。模板表达式看起来像这样。
{"属性":{“名称”:fme: get-attribute (“properties.name”),“类型”:fme: get-attribute (“properties.type”)、“模板”:fme: get-attribute (“properties.template”)、“id”: fme: get-attribute (“properties.id”)、“TRANDESCRI”: fme: get-attribute (“properties.TRANDESCRI”)、“SLOPE_PCT”: fme: get-attribute (“properties.SLOPE_PCT”)、“PVMTCATEGO”: fme: get-attribute (“properties.PVMTCATEGO”)、“PARKBOULEV”: fme: get-attribute (“properties.PARKBOULEV”)、“SHAPE_Leng”:fme: get-attribute (“properties.SHAPE_Leng”)、“_related_candidates”: fme: get-attribute (“properties._related_candidates”)、“描述”:{“名称”:fme: get-attribute (“properties.name”),“类型”:fme: get-attribute (“properties.type”)、“模板”:fme: get-attribute (“properties.template”)、“id”: fme: get-attribute (properties.id)}}}
JSONTemplater支持使用JSONiq扩展执行XQuery表达式。这个高级模板表达式不需要进行展平操作。假设名为“_json”的特性属性存储了源JSON文档。
{let $properties:= fme:get-json-attribute("_json")("properties") return {"properties": {| $properties, {"description": {| for $name in ("name", "type", "template", "id")
©2019安全亚搏在线软件公司法律