Apache Nifi 验证嵌套 Json
Apache Nifi Validating Nested Json
我正在使用 Apache Nifi 验证记录,使用 Avro 模式对嵌套 Json。 JSON.
中的 map
字段存在特殊问题
架构:
{
"type": "record",
"name": "Test",
"namespace": "test_events",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "test_attributes",
"type": {
"type": "record",
"name": "test_attributes.instance",
"fields": [
{
"name": "normal_field",
"type": [
"null",
"string"
]
},
{
"name": "nested_field",
"type": [
"null",
{
"type": "map",
"values": [
"null",
"int"
]
}
]
}
]
}
}
]
}
Json数据:
{
"id": "aplhanum123",
"test_attributes": {
"normal_field": "normal",
"nested_field": {
"meaning": 42
}
}
}
无效消息:
Records in this FlowFile were invalid for the following reasons: ; The
following 1 fields had values whose type did not match the schema:
[/test_attributes/nested_field]
我不明白这条消息。我想 Json 中的 nested_field
是有效的 map
,因此不应被处理器无效。我错过了什么?
编辑:
* 删除了示例 JSON 中的 }
。
* Nifi-1.7.1,使用 JsonTreeReader
验证记录
发现 NIFI-5678
(承认存在错误)https://github.com/apache/nifi/pull/3060/commits/c66de368d07f37a8652c09e4b116b232972821ac
已在版本 1.8.0 中发布。
我正在使用 Apache Nifi 验证记录,使用 Avro 模式对嵌套 Json。 JSON.
中的map
字段存在特殊问题
架构:
{
"type": "record",
"name": "Test",
"namespace": "test_events",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "test_attributes",
"type": {
"type": "record",
"name": "test_attributes.instance",
"fields": [
{
"name": "normal_field",
"type": [
"null",
"string"
]
},
{
"name": "nested_field",
"type": [
"null",
{
"type": "map",
"values": [
"null",
"int"
]
}
]
}
]
}
}
]
}
Json数据:
{
"id": "aplhanum123",
"test_attributes": {
"normal_field": "normal",
"nested_field": {
"meaning": 42
}
}
}
无效消息:
Records in this FlowFile were invalid for the following reasons: ; The following 1 fields had values whose type did not match the schema: [/test_attributes/nested_field]
我不明白这条消息。我想 Json 中的 nested_field
是有效的 map
,因此不应被处理器无效。我错过了什么?
编辑:
* 删除了示例 JSON 中的 }
。
* Nifi-1.7.1,使用 JsonTreeReader
发现 NIFI-5678
(承认存在错误)https://github.com/apache/nifi/pull/3060/commits/c66de368d07f37a8652c09e4b116b232972821ac
已在版本 1.8.0 中发布。