You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用JOLT Parser无法获取预期输出,请求排查Spec错误原因

Fixing Your JOLT Transform Error

First, let's break down the error you're encountering:

Error running the Transform. JOLT Chainr 'operation' must implement Transform or ContextualTransform at index:0.

This error occurs because your JOLT spec is missing a required operation type. Every JOLT transform step needs to explicitly declare what kind of transformation it's performing (like shift, modify, or default). Your current spec doesn't include this key, so JOLT can't recognize it as a valid transform.

Correct JOLT Spec to Get Your Desired Output

To split the engines array into separate objects while retaining the parent ownerId and vehicleId, use a shift operation with this spec:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "engines": {
          "*": {
            "@2,ownerId": "[&1].ownerId",
            "@2,vehicleId": "[&1].vehicleId",
            "@": "[&1].engines"
          }
        }
      }
    }
  }
]

How This Spec Works:

  • "operation": "shift" tells JOLT we're rearranging data from the input structure to the output structure.
  • The outer * targets the single object in your input array.
  • "engines": { "*": { ... } } iterates over each element in the engines array.
  • @2,ownerId and @2,vehicleId: The @2 means "go up 2 levels in the input hierarchy" (from the current engine object to the parent object holding ownerId and vehicleId), then grabs those values.
  • "[&1].ownerId": The &1 refers to the index of the current engine in the engines array, so each engine becomes a separate element in the output array.
  • @ copies the entire current engine object into the engines field of the new output object.

Testing the Spec

When you run this transform on your input:

[ { "ownerId": "XTV7I728", "vehicleId": "999", "engines": [ { "engineId": "1", "engineName": "Standard Engine", "engineHp": 300 }, { "engineId": "2", "engineName": "Custom Engine", "engineHp": 450 } ] } ]

You'll get exactly your desired output:

[{ "ownerId": "XTV7I728", "vehicleId": "999", "engines":{ "engineId": "1", "engineName": "Standard Engine", "engineHp": 300 } }, { "ownerId": "XTV7I728", "vehicleId": "999", "engines":{ "engineId": "2", "engineName": "Custom Engine", "engineHp": 450 } }]

内容的提问来源于stack exchange,提问作者whatsinthename

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 17:57:30