我希望使用可用于将输入转换为输出的JoltTransformJSON
规范。
我尝试过使用map to List和其他语法,但到目前为止都没有成功。
预期输入:
{
"params": "sn=GH6747246T4JLR6AZ&c=QUERY_RECORD&p=test_station_name&p=station_id&p=result&p=mac_addresss"
}
预期输出:
{
"queryType": "scan",
"dataSource": "xyz",
"resultFormat": "list",
"columns": ["test_station_name", "station_id", "result", "mac_address"],
"intervals": ["2018-01-01/2018-02-09"],
"filter": {
"type": "selector",
"dimension": "sn",
"value": "GH6747246T4JLR6AZ"
}
}
除了列中的内容以及维度和值属性之外,其余的字段都是硬编码的。
发布于 2018-07-28 03:18:04
由于所有数据都包含在单个JSON键/值中,因此我不认为JoltTransformJSON
是这里的最佳选择。实际上,我认为在Python/Groovy/Ruby中编写一个简单的脚本来拆分querystring值并将其写出为JSON更容易,维护起来也不那么复杂。我特别推荐Groovy (您可以使用专门的ExecuteGroovyScript
处理器),因为它是Apache NiFi中的most performant & robust,并且具有excellent JSON handling。
https://stackoverflow.com/questions/51532246
复制相似问题