所以我有地理坐标,我想创建多边形字符串,我可以将其作为几何类型插入到Postgres中.我正在使用apache Nifi.

输入:

[
  [
    13,
    52
  ],
  [
    13,
    55
  ],
  [
    14,
    15
  ]
]

预期输出:

POLYGON((13 52, 13 55, 14 15))

我try 了下面的颠簸,但没有成功:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": "[&1].[&0]"
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": "&"
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        "*": "=join(' ',@(1,&))"
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": "=concat('POLYGON((',@(1,2),'))')"
    }
  }
]

推荐答案

您可以将当前版本转换为以下格式:

[
  { // form independent arrays with keys of indexes taken from the outermost array
    "operation": "shift",
    "spec": {
      "*": {
        "*": "&1"
      }
    }
  },
  { // stringify those arrays
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": "=join(' ',@(1,&))"
    }
  },
  { // generate an array namely "Coord"
    "operation": "shift",
    "spec": {
      "*": {
        "@": "Coord"
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "Coord": "=join(' ,',@(1,&))",
      "*": "=concat('POLYGON((',@(1,&),'))')"
    }
  }
]

现场https://jolt-demo.appspot.com/上的demo个是:

enter image description here

Json相关问答推荐

嵌套自定义解组

JOLT转换过滤出特定值/对象

如何将响应数据保存到Flutter 中的共享首选项中

父键中的 Perl JSON 数组

使用 jq 和 awk 拆分大型 JSON 文件

嵌套 JSON 到 CSV(多级)

为什么在测试 RSPEC 时 JBuilder 不返回 JSON 中的响应正文

获取json中某个键的索引

Qt使用QJsonDocument、QJsonObject、QJsonArray解析JSON

在 JavaScript 中从 Json 数据中删除反斜杠

如何为名称/值 struct 创建 JSON 模式?

验证和格式化 JSON 文件

Golang struct 的 XML 和 JSON 标签?

如何创建 JSON 对象 Node.js

PostgreSQL 中的 JSON 模式验证?

使用 jq 如何用其他名称替换键的名称

json_encode() 返回 false

为什么 RestTemplate 不将响应表示绑定到 PagedResources?

我如何反序列化以杰克逊为单位的时间戳?

使用 JavaScriptSerializer() 反序列化 JSON 文件