JUST JSON嵌套数组循环转换问题求助
问题解决:JUST转换嵌套数组字段重命名
报错翻译
解析路径索引器时遇到意外字符: $
错误原因
你在#loop循环内部使用了带$前缀的全局路径(比如$.vars、$.rows),但JUST在循环上下文里会切换到当前数组元素的局部作用域,不支持这种全局路径写法,导致解析报错。
正确映射配置
以下两种写法都可以实现需求:
写法1:用#current直接引用当前循环项
{"vars": {"#loop(vars)": { "table": "#current.table", "rows": {"#loop(rows)": { "diff_col1": "#current.col1", "diff_col2": "#current.col2", "diff_col3": "#current.col3", "diff_col4": "#current.col4" }} }}}
写法2:用相对路径的#currentvalueatpath
{"vars": {"#loop(vars)": { "table": "#currentvalueatpath(table)", "rows": {"#loop(rows)": { "diff_col1": "#currentvalueatpath(col1)", "diff_col2": "#currentvalueatpath(col2)", "diff_col3": "#currentvalueatpath(col3)", "diff_col4": "#currentvalueatpath(col4)" }} }}}
说明
这个场景完全支持,核心是在循环内部使用局部上下文的引用方式,去掉全局路径的$前缀,改用#current或者相对路径的字段名即可。
内容的提问来源于stack exchange,提问作者bruce neiman
相关产品推荐
相关产品推荐

