-
Notifications
You must be signed in to change notification settings - Fork 255
[json]Transformer
Sun Jianbo edited this page Mar 20, 2018
·
3 revisions
该transformer可以解析json类型数据。
在Parser后使用,针对key指定的json字段进行解析,解析成json的interface类型赋予指定的字段。
{
"type":"json",
"key":"myOldKey",
"new":"myNewKey",
}
-
key
指定要解析的json数据所在的字段,支持多级嵌套,多级间用*.* 符号连接,表示data["abc"]["xyz"] 中的数据。 -
new
指定要解析json数据字段的新字段,必须指定新字段。
{
"name":"test2.csv",
"reader":{
"log_path":"./tests/logdir",
"mode":"dir"
},
"parser":{
"name":"jsonps",
"type":"json"
},
"transforms":[{
"type":"json",
"key":"myOldKey",
"new":"myNewKey"
}],
"senders":[{
"name":"file_sender",
"sender_type":"file",
"file_send_path":"./test2/test2_csv_file.txt"
}]
}
例如, parser 解析后的数据为:
{
"field1": "aaaa",
"field2": "bbbb",
"myOldKey": "{"uid":123,"name":"tom","age":10}"
}
经过json变换后的数据将变为:
{
"field1": "aaaa",
"field2": "bbbb",
"myOldKey": "{\"uid\":123,\"name\":\"tom\",\"age\":10}"
"myNewKey": {"uid":123,"name":"tom","age":10}
}
快速开始 | Pandora | Readers | Parsers | Senders | Download | 七牛智能日志管理平台 | logkit-pro专业版