我有一个简单的要求,即在 Mule 4 中将输入 JSON 转换为平面文件,但我无法在网上找到任何可靠的示例。我开始按如下方式创建示例架构,但它不起作用。
test.ffd 架构:
form: FLATFILE
id: 'test'
tag: '1'
name: Request Header Record
values:
- { name: 'aa', type: String, length: 10 }
- { name: 'bb', type: String, length: 8 }
- { name: 'cc', type: String, length: 4 }
数据编织:
%dw 2.0
output application/flatfile schemaPath='test.ffd'
---
{
aa : payload.a,
bb : payload.b,
cc : payload.c
}
输入 JSON:
{
"a": "xxx",
"b": "yyy",
"c": "zzz"
}
但它没有说
Message : "java.lang.IllegalStateException - Need to specify structureIdent or schemaIdent in writer configuration, while writing FlatFile at
4| {
| ...
8| }
如何正确执行此操作?
最佳答案
错误消息告诉您错过了什么。
Need to specify structureIdent or schemaIdent in writer configuration
添加其中之一,它的平面文件或固定宽度应该可以正常工作。
例如,添加segmentIdent:
%dw 2.0
output application/flatfile schemaPath = "test1.ffd",
segmentIdent = "test1"
---
payload map (a, index) -> {
aa: a.a,
bb: a.b,
cc: a.c
}
以下是如何正确使用 FIXEDWIDTH 的示例 https://simpleflatservice.com/mule4/FixedWidthSchemaTransformation.html
关于java - Mule 4 中的 JSON 到平面文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60670830/