talend - 从 Talend 中的 JSON 文件中提取值
问题描述
我有这样的json文件:
{"2020-04-28":
{
"37,N7L2H4,Carry,CHOPA,PLX":
{
"inter_results": {
"inter_mark": "GITA"
,"down": null
,"up": null
,"wiki": {"included": "false", "options": ["RRR", "SSS","HHH"]
}}
,"38, N5L2J4, HURT, SERRA, PZT": {
"inter_results": {
"inter_mark": "MARI"
,"down": "250"
,"up": "1250"
,"wiki": {"included": "true", "options": ["XXX", "YYY"]
}}
,"39, N4L2H4, HIBA, FILA, PFG": {
"inter_results": {
"inter_mark": "HILO"
,"down": "100"
,"up": "250"
,"wiki": {"included": "true", "options": ["RTG", "VTH","HJI","JKL"]
}}
}
}
我想使用withN7L2H4,N5L2J4,N4L2H4
从此 json 文件中提取值。tFileInputJson
jsonPath
解决方案
使用 Talend 的原生组件,这很难实现。你可以用一些java代码来做,但这并不优雅。
这是使用来自 Talend Exchange 的 json 组件套件的解决方案,您可以在此处下载
该组件tJSONDocTraverseFields
允许您列出 json 的所有字段、路径和值。它给出了这个输出:
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.inter_mark|4|inter_mark|"GITA"|false|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.down|4|down|null|false|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.up|4|up|null|false|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.wiki.included|5|included|"false"|false|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.wiki.options[0]|6|options|"RRR"|true|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.wiki.options[1]|6|options|"SSS"|true|21
$.2020-04-28.37,N7L2H4,Carry,CHOPA,PLX.inter_results.wiki.options[2]|6|options|"HHH"|true|21
$.2020-04-28.38, N5L2J4, HURT, SERRA, PZT.inter_results.inter_mark|4|inter_mark|"MARI"|false|21
$.2020-04-28.38, N5L2J4, HURT, SERRA, PZT.inter_results.down|4|down|"250"|false|21
$.2020-04-28.38, N5L2J4, HURT, SERRA, PZT.inter_results.up|4|up|"1250"|false|21
我用“。”分割路径 获取字段“37,N7L2H4,Carry,CHOPA,PLX”,然后在“”上再次拆分结果并获取第一个值。
tJSONDocOpen
允许您初始化 json 文件,它充当连接。然后在 中选择它tJSONDocTraverseFields
。
推荐阅读
- python - 当我传入参数时,Django 自定义权限无法调用装饰器
- reactjs - ReactJS:更新填写的表格并在取消后返回初始状态
- ios - 如何快速在 NSCountedSet 中放置和排序单词?
- c++ - 有没有办法在 C++/GLUT 中循环选项
- sql - 如何删除我在 1 列中得到重复的结果
- reactjs - 高级 React Typescript 功能组件声明
- react-native - 防止手机进入休眠状态
- r - R中不同大小向量的置换函数
- azure-devops - 是否可以为服务主体分配“队列构建”权限?
- entity-framework-core - 使用 EntityFrameworkCore 3.1.2 ModelBuilder 播种嵌套数据